benc


License

License

Categories

Categories

Ant Build Tools
GroupId

GroupId

com.minosiants
ArtifactId

ArtifactId

benc_2.13
Last Version

Last Version

0.7.1
Release Date

Release Date

Type

Type

jar
Description

Description

benc
benc
Project URL

Project URL

https://github.com/minosiants/benc
Project Organization

Project Organization

Kaspar Minosiants
Source Code Management

Source Code Management

https://github.com/minosiants/benc

Download benc_2.13

How to add to project

<!-- https://jarcasting.com/artifacts/com.minosiants/benc_2.13/ -->
<dependency>
    <groupId>com.minosiants</groupId>
    <artifactId>benc_2.13</artifactId>
    <version>0.7.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.minosiants/benc_2.13/
implementation 'com.minosiants:benc_2.13:0.7.1'
// https://jarcasting.com/artifacts/com.minosiants/benc_2.13/
implementation ("com.minosiants:benc_2.13:0.7.1")
'com.minosiants:benc_2.13:jar:0.7.1'
<dependency org="com.minosiants" name="benc_2.13" rev="0.7.1">
  <artifact name="benc_2.13" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.minosiants', module='benc_2.13', version='0.7.1')
)
libraryDependencies += "com.minosiants" % "benc_2.13" % "0.7.1"
[com.minosiants/benc_2.13 "0.7.1"]

Dependencies

compile (5)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.13.1
org.typelevel : cats-core_2.13 jar 2.1.0
com.chuusai : shapeless_2.13 jar 2.3.3
org.scodec : scodec-core_2.13 jar 1.11.6
org.scodec : scodec-cats_2.13 jar 1.0.0

test (3)

Group / Artifact Type Version
org.scalacheck : scalacheck_2.13 jar 1.14.1
org.specs2 : specs2-core_2.13 jar 4.8.3
org.specs2 : specs2-scalacheck_2.13 jar 4.8.3

Project Modules

There are no modules declared in this project.

Benc

build javadoc
Bencoding library for scala

Overview

Bencoding

Specification
Bencoding is a way to specify and organize data in a terse format. It supports the following types: byte strings, integers, lists, and dictionaries.

Bencoding is used in .torrent files

Benc functionality

  1. Encode case classes to bencoding
  2. Decode bencoding to case classes

Usage

libraryDependencies += "com.minosiants" %% "benc" % <version>

Example

  final case class Id(id: String)
  final case class Author(name: String, age: Option[Int])
  final case class Book(id: Id, author: Author, content: BitVector, pages: Long)
  val book = Book(...)
  //there are several ways to do conversion
   
  val bits:Either[Error, BitVector] = Benc.toBenc[Book](book)
  val backToBook:Either[Error, Book] = bits.flatMap(b => Benc.fromBenc[Book](b))

  //Using decoder adn encode directly
  BEncoder[Book].encode(book).flatMap(bt => BDecoder[Book].decode(bt))  

  //Using codec
  val codec = BCodec[Book]  
  codec.encode(book).flatMap(bt => codec.decode(bt))

  //Setting different name
  case class Pen(@BencKey("name") brand:String)
  

Versions

Version
0.7.1
0.7.0
0.6.0
0.5.0
0.4.0
0.3.2
0.3.1
0.3.0