trait Codec[A] extends AnyRef

Codecs allow a writer to deal with the case where we have a buffer overflow when attempting to write all data to the buffer. This lets the writer return some state indicating more data needs to be written. This state is then given to a writeMore method so it can finish the writing. It may take several calls to writeMore before it all is finally written.

Self Type
Codec[A]
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Codec
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. abstract type S

Abstract Value Members

  1. abstract def encodedSize(a: A): Int

    Returns the exact encoded size of a.

  2. abstract def read(buffer: ByteBuffer): A

    Reads a value of type A from buffer.

    Reads a value of type A from buffer. This should generally follow the contract that writeUnsafe(a, buffer); read(buffer) == a.

  3. abstract def writeInit(a: A, buffer: ByteBuffer): Option[S]

    Initiate a write.

    Initiate a write. If a is successfully written (in its entirety) to buffer, then None is returned. Otherwise, Some(s) is returned, indicating that some more data (ie. s) still needs to be written using writeMore(s, _). This last condition will normally happen when we run out of space in the buffer, so a was only partially written.

  4. abstract def writeMore(s: S, buffer: ByteBuffer): Option[S]

    Writes the remaining data from a call to writeInit to buffer.

    Writes the remaining data from a call to writeInit to buffer. If this is written completely and successfully, None is returned. Otherwise, Some(s2) is returned, which contains more data to be written with writeMore.

  5. abstract def writeUnsafe(a: A, buffer: ByteBuffer): Unit

    Performs an *unsafe* write of a to buffer.

    Performs an *unsafe* write of a to buffer. This does not perform any safety checks and assumes buffer has at least encodedSize(a) bytes remaining. The behaviour if this is not the case is undefined.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def as[B](to: (B) ⇒ A, from: (A) ⇒ B): Codec[B]
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. def maxSize(a: A): Int

    Returns an upper bound on the size of a.

  14. def minSize(a: A): Int

    Returns a lower bound on the space required in a buffer so that a can be written.

  15. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. def skip(buffer: ByteBuffer): Unit

    This is similar to read(buffer), except that a value does not actually need to be returned.

  19. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  20. def toString(): String
    Definition Classes
    AnyRef → Any
  21. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  24. def write[M[_]](a: A)(implicit M: ByteBufferMonad[M]): M[Unit]

    Writes a using a ByteBufferMonad.

    Writes a using a ByteBufferMonad. This is much slower than just using writeInit/writeMore.

  25. def writeAll(a: A)(acquire: () ⇒ ByteBuffer, used: List[ByteBuffer] = Nil): List[ByteBuffer]

    Writes a entirely to a series of ByteBuffers returned by acquire.

    Writes a entirely to a series of ByteBuffers returned by acquire. The returned set of ByteBuffers is in reverse order, so that calls to writeAll can be chained by passing in the previous result to used.

Inherited from AnyRef

Inherited from Any

Ungrouped