Skip to content

Fast, typesafe and boilerplate-free object serialization in Scala

License

Notifications You must be signed in to change notification settings

andresilva/bytes

Repository files navigation

bytes

A playground for fast, typesafe and boilerplate-free object serialization in Scala.

This is what we've got so far:

import io.github.andrebeat.bytes._

case class Foo(
  b: Byte,
  s: Short,
  c: Char,
  i: Int,
  f: Float,
  l: Long,
  d: Double,
  is: List[Int],
  set: Set[Char],
  map: Map[Long, Int],
  opt: Option[Float],
  either: Either[Byte, Int])

val foo = Foo(
    1, 42, '?', 13231, 9023.0f, 55554434L, 321.0,
    1 :: 2 :: 3 :: Nil,
    Set('a', 'b', 'c'),
    Map(99L -> 0, 98L -> 1),
    None,
    Right(4))

val bytes: Bytes = UnsafeBytes(1024)

Write(bytes, 0, foo)
// res0: Int = 83

val (foo2, size) = Read[Foo](bytes, 0)
// foo2: Foo = Foo(1,42,?,13231,9023.0,55554434,321.0,List(1, 2, 3),Set(a, b, c),Map(99 -> 0, 98 -> 1),None,Right(4))
// size: Int = 83

About

Fast, typesafe and boilerplate-free object serialization in Scala

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published