Trait MessageWrite

Source
pub trait MessageWrite {
    type Output;

    // Required methods
    fn mut_data(&mut self) -> &mut [u8] ;
    fn data(&self) -> &[u8] ;
    fn len(&self) -> usize;
    fn push_data(&mut self, data: &[u8]);
    fn push_attribute_unchecked(&mut self, attr: &dyn AttributeWrite);
    fn finish(self) -> Self::Output;

    // Provided methods
    fn max_size(&self) -> Option<usize> { ... }
    fn has_attribute(&self, atype: AttributeType) -> bool { ... }
    fn has_any_attribute(
        &self,
        atypes: &[AttributeType],
    ) -> Option<AttributeType> { ... }
}
Expand description

Trait for implementing a writer for Messages.

Required Associated Types§

Source

type Output

The output of this MessageWrite

Required Methods§

Source

fn mut_data(&mut self) -> &mut [u8]

A mutable reference to the contained data.

Source

fn data(&self) -> &[u8]

A reference to the contained data.

Source

fn len(&self) -> usize

The length of the currently written data.

Source

fn push_data(&mut self, data: &[u8])

Append the provided data to the end of the output.

Source

fn push_attribute_unchecked(&mut self, attr: &dyn AttributeWrite)

Write an attribute to the end of the Message.

Source

fn finish(self) -> Self::Output

Finishes and returns the built Message.

Provided Methods§

Source

fn max_size(&self) -> Option<usize>

Return the maximum size of the output. If the output data is not bound to a fixed size, None should be returned.

Source

fn has_attribute(&self, atype: AttributeType) -> bool

Return whether this MessageWrite contains a particular attribute.

Source

fn has_any_attribute(&self, atypes: &[AttributeType]) -> Option<AttributeType>

Return whether this MessageWrite contains any of the provided attributes and returns the attribute found.

Implementors§