[][src]Struct dusk_tlv::TlvWriter

pub struct TlvWriter<W> where
    W: Write
{ /* fields omitted */ }
[]

Optionally consumes an implementation of io::Write, and provides an adapter to convert slices of bytes to TLV format, and output the result to the writer.

Methods

impl<W> TlvWriter<W> where
    W: Write
[src][]

pub fn new(writer: W) -> Self[src][]

TlvWriter constructor

pub fn into_inner(self) -> W[src][]

Consumes self, and return the inner writer

pub fn bytes_len_to_writer(writer: W, len: usize) -> Result<usize, Error>[src][]

Convert the provided slice of bytes to TLV format, and write the TL to the writer

pub fn bytes_to_writer(writer: W, buf: &[u8]) -> Result<usize, Error>[src][]

Convert the provided slice of bytes to TLV format, output the result to the provided writer, and return the amount of bytes written.

pub fn write_usize(&mut self, n: usize) -> Result<usize, Error>[src][]

Append the provided usize to the writer in TLV format

pub fn write_list<L: AsRef<[u8]>>(&mut self, list: &[L]) -> Result<usize, Error>[src][]

Write a list of serializable items

Trait Implementations

impl<W> Write for TlvWriter<W> where
    W: Write
[src][+]

fn write(&mut self, buf: &[u8]) -> Result<usize, Error>[src][]

The io::Write::write implementation will internally call the TlvWriter::bytes_to_writer. Therefore, the provided buffer will first be converted to TLV format, and then sent to the inner writer.

fn flush(&mut self) -> Result<(), Error>[src][]

The io::Write::flush implementation will just forward the call to the inner writer.

impl<'a, W> SerializeTuple for &'a mut TlvWriter<W> where
    W: Write
[src][+]

type Ok = ()

Must match the Ok type of our Serializer.

type Error = Error

Must match the Error type of our Serializer.

impl<'a, W> Serializer for &'a mut TlvWriter<W> where
    W: Write
[src][+]

type Ok = ()

The output type produced by this Serializer during successful serialization. Most serializers that produce text or binary output should set Ok = () and serialize into an [io::Write] or buffer contained within the Serializer instance. Serializers that build in-memory data structures may be simplified by using Ok to propagate the data structure around. Read more

type Error = Error

The error type when some error occurs during serialization.

type SerializeSeq = Self

Type returned from [serialize_seq] for serializing the content of the sequence. Read more

type SerializeTuple = Self

Type returned from [serialize_tuple] for serializing the content of the tuple. Read more

type SerializeTupleStruct = Self

Type returned from [serialize_tuple_struct] for serializing the content of the tuple struct. Read more

type SerializeTupleVariant = Self

Type returned from [serialize_tuple_variant] for serializing the content of the tuple variant. Read more

type SerializeMap = Self

Type returned from [serialize_map] for serializing the content of the map. Read more

type SerializeStruct = Self

Type returned from [serialize_struct] for serializing the content of the struct. Read more

type SerializeStructVariant = Self

Type returned from [serialize_struct_variant] for serializing the content of the struct variant. Read more

impl<'a, W> SerializeMap for &'a mut TlvWriter<W> where
    W: Write
[src][+]

type Ok = ()

Must match the Ok type of our Serializer.

type Error = Error

Must match the Error type of our Serializer.

impl<'a, '_, W> SerializeSeq for &'_ mut TlvWriter<W> where
    W: Write
[src][+]

type Ok = ()

Must match the Ok type of our Serializer.

type Error = Error

Must match the Error type of our Serializer.

impl<'a, W> SerializeStruct for &'a mut TlvWriter<W> where
    W: Write
[src][+]

type Ok = ()

Must match the Ok type of our Serializer.

type Error = Error

Must match the Error type of our Serializer.

impl<'a, W> SerializeStructVariant for &'a mut TlvWriter<W> where
    W: Write
[src][+]

type Ok = ()

Must match the Ok type of our Serializer.

type Error = Error

Must match the Error type of our Serializer.

impl<'a, W> SerializeTupleStruct for &'a mut TlvWriter<W> where
    W: Write
[src][+]

type Ok = ()

Must match the Ok type of our Serializer.

type Error = Error

Must match the Error type of our Serializer.

impl<'a, W> SerializeTupleVariant for &'a mut TlvWriter<W> where
    W: Write
[src][+]

type Ok = ()

Must match the Ok type of our Serializer.

type Error = Error

Must match the Error type of our Serializer.

Auto Trait Implementations

impl<W> Send for TlvWriter<W> where
    W: Send

impl<W> Sync for TlvWriter<W> where
    W: Sync

impl<W> Unpin for TlvWriter<W> where
    W: Unpin

impl<W> UnwindSafe for TlvWriter<W> where
    W: UnwindSafe

impl<W> RefUnwindSafe for TlvWriter<W> where
    W: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src][+]

impl<T> From<T> for T[src][+]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src][+]

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src][+]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src][+]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src][+]

impl<T> Any for T where
    T: 'static + ?Sized
[src][+]