Trait anchor::OutputBuffer

source ·
pub trait OutputBuffer {
    type Cursor: Copy;

    // Required methods
    fn output(&mut self, buf: &[u8]);
    fn cur_position(&self) -> Self::Cursor;
    fn update(&mut self, cursor: Self::Cursor, value: u8);
    fn data_since(&self, cursor: Self::Cursor) -> &[u8] ;
}
Expand description

Trait for output buffers that can accept encoded data.

Message builders accept an argumenet of this type and will output their data in to the buffer.

The buffer must support simple seeking to a previously retrieved position. This is used when calculating checksums.

Required Associated Types§

source

type Cursor: Copy

The cursor type

Required Methods§

source

fn output(&mut self, buf: &[u8])

Append bytes to the buffer

source

fn cur_position(&self) -> Self::Cursor

Retrieve the cursor representing the position of the last appended byte

source

fn update(&mut self, cursor: Self::Cursor, value: u8)

Replace the byte at the cursor position with a new value

source

fn data_since(&self, cursor: Self::Cursor) -> &[u8]

Retrieve a reference to all data pushed after the cursor

Implementations on Foreign Types§

source§

impl OutputBuffer for Vec<u8>

§

type Cursor = usize

source§

fn output(&mut self, buf: &[u8])

source§

fn cur_position(&self) -> Self::Cursor

source§

fn update(&mut self, cursor: Self::Cursor, value: u8)

source§

fn data_since(&self, cursor: Self::Cursor) -> &[u8]

Implementors§

source§

impl<const MAX_SIZE: usize> OutputBuffer for ScratchOutput<MAX_SIZE>