Documentation ¶
Index ¶
- Constants
- func Marshal(data CborMarshaler, w io.Writer) error
- func ReadArrayLength(r io.Reader) (n uint64, err error)
- func ReadBoolean(r io.Reader) (b bool, err error)
- func ReadByteString(r io.Reader) (data []byte, err error)
- func ReadByteStringLen(r io.Reader) (n uint64, err error)
- func ReadExpect(b byte, r io.Reader) error
- func ReadExpectMajors(m MajorType, r io.Reader) (n uint64, err error)
- func ReadFloat32(r io.Reader) (f float32, err error)
- func ReadFloat64(r io.Reader) (f float64, err error)
- func ReadMapPairLength(r io.Reader) (n uint64, err error)
- func ReadRawBytes(l uint64, r io.Reader) (data []byte, err error)
- func ReadTextString(r io.Reader) (data string, err error)
- func ReadTextStringLen(r io.Reader) (n uint64, err error)
- func ReadUInt(r io.Reader) (n uint64, err error)
- func Unmarshal(data CborMarshaler, r io.Reader) error
- func WriteArrayLength(n uint64, w io.Writer) error
- func WriteBoolean(b bool, w io.Writer) (err error)
- func WriteByteString(data []byte, w io.Writer) error
- func WriteByteStringLen(n uint64, w io.Writer) error
- func WriteFloat32(f float32, w io.Writer) (err error)
- func WriteFloat64(f float64, w io.Writer) (err error)
- func WriteMajors(m MajorType, n uint64, w io.Writer) (err error)
- func WriteMapPairLength(n uint64, w io.Writer) error
- func WriteTextString(data string, w io.Writer) error
- func WriteTextStringLen(n uint64, w io.Writer) error
- func WriteUInt(n uint64, w io.Writer) error
- type CborMarshaler
- type Flag
- type MajorType
Constants ¶
const ( IndefiniteArray byte = 0x9F BreakCode byte = 0xFF )
const ( FlagIndefiniteArray = Flag(iota) FlagBreakCode = Flag(iota) )
Variables ¶
This section is empty.
Functions ¶
func Marshal ¶
func Marshal(data CborMarshaler, w io.Writer) error
Marshal writes a CBOR representation of a CborMarshaler into the Writer.
func ReadArrayLength ¶
ReadArrayLength expects an array at the Reader's position and returns its length.
func ReadBoolean ¶ added in v0.1.2
ReadBoolean reads a bool value from the Reader.
func ReadByteString ¶
ReadByteStringLen expects a byte string at the Reader's position and returns the byte string.
func ReadByteStringLen ¶
ReadByteStringLen expects a byte string at the Reader's position and returns the byte string's length.
func ReadExpect ¶
ReadExpect reads one byte from the Reader and errors if it does not contain the expected value. This might be useful to check if an indefinite-length array begins or ends with an break stop code.
func ReadExpectMajors ¶
ReadExpectMajors parses the next (major) type, which must equal the requested one. This function wraps ReadMajors.
func ReadFloat32 ¶ added in v0.1.4
ReadFloat32 reads a float32 value from the Reader.
func ReadFloat64 ¶ added in v0.1.4
ReadFloat64 reads a float64 value from the Reader.
func ReadMapPairLength ¶ added in v0.1.3
ReadMapPairLength expects a map at the Reader's position and returns the amount of pairs stored.
func ReadRawBytes ¶
ReadRawBytes reads the next l bytes from r into a new byte slice.
func ReadTextString ¶
ReadTextStringLen expects a text string at the Reader's position and returns the text string.
func ReadTextStringLen ¶
ReadTextStringLen expects a text string at the Reader's position and returns the text string's length.
func Unmarshal ¶
func Unmarshal(data CborMarshaler, r io.Reader) error
Unmarshal reads a CBOR representation from a Reader into a CborMarshaler.
func WriteArrayLength ¶
WriteArrayLength writes the type definition for an array with the given length into the Writer.
func WriteBoolean ¶ added in v0.1.2
WriteBoolean writes a bool into the Writer.
func WriteByteString ¶
WriteByteString writes a byte string into the Writer.
func WriteByteStringLen ¶
WriteByteStringLen writes the type definition for a byte string with the given length into the Writer.
func WriteFloat32 ¶ added in v0.1.4
WriteFloat32 writes a float32 into the Writer.
func WriteFloat64 ¶ added in v0.1.4
WriteFloat64 writes a float64 into the Writer.
func WriteMajors ¶
WriteMajors composes a (major) type definition into the Writer.
func WriteMapPairLength ¶ added in v0.1.3
WriteMapPairLength writes the type definition for a map with the given amount of pairs into the Writer.
func WriteTextString ¶
WriteTextString writes a byte string into the Writer.
func WriteTextStringLen ¶
WriteTextStringLen writes the type definition for a text string with the given length into the Writer.
Types ¶
type CborMarshaler ¶
CborMarshaler is the interface implemented by an object that can both marshal itself into a CBOR form and unmarshal a CBOR representation of itself.
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
endpoint
Package endpoint contains a simplified version of the EndpointID struct from the dtn7-go <https://github.com/dtn7/dtn7-go> application.
|
Package endpoint contains a simplified version of the EndpointID struct from the dtn7-go <https://github.com/dtn7/dtn7-go> application. |
payloadblock
Package payloadblock contains a simplified version of a PayloadBlock, which is a characteristic of a CanonicalBlock, from the dtn7-go <https://github.com/dtn7/dtn7-go> application.
|
Package payloadblock contains a simplified version of a PayloadBlock, which is a characteristic of a CanonicalBlock, from the dtn7-go <https://github.com/dtn7/dtn7-go> application. |