ByteCodec

org.sigilaris.core.codec.byte.ByteCodec
See theByteCodec companion trait
object ByteCodec

Attributes

Companion
trait
Source
ByteCodec.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
ByteCodec.type

Members list

Value members

Concrete methods

def apply[A : ByteCodec]: ByteCodec[A]

Summons a ByteCodec instance for type A.

Summons a ByteCodec instance for type A.

Attributes

Source
ByteCodec.scala
def opaqueProduct[A, Repr](wrap: Repr => A, unwrap: A => Repr)(using codec: ByteCodec[Repr]): ByteCodec[A]

Helper for opaque wrappers backed by a product representation.

Helper for opaque wrappers backed by a product representation.

The representation's codec remains the single source of truth while the wrapper supplies only the wrapping and unwrapping functions.

Type parameters

A

the opaque wrapper type

Repr

the underlying representation type

Value parameters

unwrap

function to unwrap the opaque type to its representation

wrap

function to wrap the representation into the opaque type

Attributes

Returns

a ByteCodec for the opaque wrapper type

Source
ByteCodec.scala

Givens

Givens

given given_ByteCodec_A[A : ByteDecoder : ByteEncoder]: given_ByteCodec_A[A]

Automatic derivation when both encoder and decoder are available.

Automatic derivation when both encoder and decoder are available.

For any type A with both ByteEncoder[A] and ByteDecoder[A], a ByteCodec[A] is automatically available.

Attributes

Example
 case class User(id: Long, name: String)
 // ByteCodec[User] is automatically available via derivation
 val codec = ByteCodec[User]
Source
ByteCodec.scala