Struct blaze_pk::writer::TdfWriter

source ·
pub struct TdfWriter {
    pub buffer: Vec<u8>,
}
Expand description

Writer implementation for writing values to an underlying buffer this writer implementation provides functions for writing certain data types in their Blaze format

Fields§

§buffer: Vec<u8>

The buffer that will be written to

Implementations§

source§

impl TdfWriter

source

pub fn write_byte(&mut self, value: u8)

Writes a single byte to the underlying buffer. This just appends the byte to the buffer.

value The value to write

source

pub fn write_slice(&mut self, value: &[u8])

Extends the underlying buffer with the provided slice value.

value The slice value to write

source

pub fn write_type(&mut self, ty: TdfType)

Writes the value type byte of the provided TdfType

ty The type to write

source

pub fn tag(&mut self, tag: &[u8], value_type: TdfType)

Writes a tag vvalue to the underlying buffer

tag The tag bytes to write value_type The value type for the tag

source

pub fn tag_bool(&mut self, tag: &[u8], value: bool)

Writes a new tag to the buffer with a boolean as the tag value.

tag The tag to write value The tag value boolean

source

pub fn tag_zero(&mut self, tag: &[u8])

Writes a new tag where the value is a VarInt that is simply zero so the encoding can skip all the var int logic and directly write zero

tag The tag to write

source

pub fn tag_u8(&mut self, tag: &[u8], value: u8)

Writes a new tag where the value is a u8 value using the var int encoding

tag The tag to write value The value to write

source

pub fn tag_u16(&mut self, tag: &[u8], value: u16)

Writes a new tag where the value is a u16 value using the var int encoding

tag The tag to write value The value to write

source

pub fn tag_u32(&mut self, tag: &[u8], value: u32)

Writes a new tag where the value is a u32 value using the var int encoding

tag The tag to write value The value to write

source

pub fn tag_u64(&mut self, tag: &[u8], value: u64)

Writes a new tag where the value is a u64 value using the var int encoding

tag The tag to write value The value to write

source

pub fn tag_usize(&mut self, tag: &[u8], value: usize)

Writes a new tag where the value is a usize value using the var int encoding

tag The tag to write value The value to write

source

pub fn tag_str_empty(&mut self, tag: &[u8])

Writes a new tag where the value is an empty string

tag The tag to write

source

pub fn tag_empty_blob(&mut self, tag: &[u8])

Writes a new tag where the value is an empty blob. Empty blobs are simply encoded with a zero length

tag The tag to write

source

pub fn tag_str(&mut self, tag: &[u8], value: &str)

Writes a new tag where the value is a string.

tag The tag to write value The value to write

source

pub fn tag_group(&mut self, tag: &[u8])

Writes a new tag indicating the start of a new group

tag The tag to write

source

pub fn tag_group_end(&mut self)

Writes the zero value that indicates the end of a group

source

pub fn group<F>(&mut self, tag: &[u8], gr: F)where F: FnOnce(&mut Self),

Writes a group opening tag and then completes the group function and closes the group tag

tag The tag to write gr The group closure

source

pub fn tag_list_start(&mut self, tag: &[u8], ty: TdfType, length: usize)

Writes a new tag indicating that a list is begining and writes the list type and length

tag The tag to write ty The type of items being written after length The number of items that will be written

source

pub fn tag_union_start(&mut self, tag: &[u8], key: u8)

Writes a new tag indicating that a union with the provided key is starting

tag The tag to write key The key to write

source

pub fn tag_union_value<C: Encodable + ValueType>( &mut self, tag: &[u8], key: u8, value_tag: &[u8], value: &C )

Writes a new union tag with its value

tag The tag to write key The key of the union value_tag The tag for the value value The value to write

source

pub fn tag_union_unset(&mut self, tag: &[u8])

Writes a new tag indicating a union with no value

tag The tag to write

source

pub fn tag_value<C: Encodable + ValueType>(&mut self, tag: &[u8], value: &C)

Writes a tag and its value where the value implements ValueType

tag The tag to write value The value to write

source

pub fn tag_list_empty(&mut self, tag: &[u8], ty: TdfType)

Writes a tag for indiciating a list with no contents

tag The tag to write ty The type of the empty list

source

pub fn tag_slice_list<C: Encodable + ValueType>( &mut self, tag: &[u8], value: &[C] )

Slices are already borrowed so they confuse the tag_value type using this function instead makes them work

source

pub fn tag_var_int_list_empty(&mut self, tag: &[u8])

Writes a tag for indiciating a var int list with no contents

tag The tag to write

source

pub fn tag_map_start( &mut self, tag: &[u8], key: TdfType, value: TdfType, length: usize )

Writes a tag indicating that a map will be written for the provided types and length

tag The tag to write key The key tdf type value The value tdf type length The total number of entires that will be written

source

pub fn tag_pair<A, B>(&mut self, tag: &[u8], value: (A, B))where A: VarInt, B: VarInt,

Writes a tag with a pair of values

tag The tag to write value The value to write

source

pub fn tag_triple<A, B, C>(&mut self, tag: &[u8], value: (A, B, C))where A: VarInt, B: VarInt, C: VarInt,

Writes a tag with a triple of values

tag The tag to write value The value to write

source

pub fn write_empty_str(&mut self)

Writes an empty string. This is simply two bytes a 1 and a 0 which indicate a string consisting of only a null terminator

source

pub fn write_f32(&mut self, value: f32)

Writes 32 bit float value to the underlying buffer in big-endian byte order.

value The float value to write

source

pub fn write_u8(&mut self, value: u8)

Writes a u8 value using the VarInt encoding

value The value to write

source

pub fn write_u16(&mut self, value: u16)

Writes a u16 value using the VarInt encoding

value The value to write

source

pub fn write_u32(&mut self, value: u32)

Writes a u32 value using the VarInt encoding

value The value to write

source

pub fn write_u64(&mut self, value: u64)

Writes a u64 value using the VarInt encoding

value The value to write

source

pub fn write_usize(&mut self, value: usize)

Writes a usize value using the VarInt encoding

value The value to write

source

pub fn write_str(&mut self, value: &str)

Writes a string to the underlying buffer. The bytes are encoded an a null terminator is appended to the end then the size and bytes are written to the buffer

value The string value to write

source

pub fn write_bool(&mut self, value: bool)

Writes a boolean value which uses the VarInt encoding except because the values are < 64 they are just directly appended as bytes

source

pub fn write_map_header( &mut self, key_type: TdfType, value_type: TdfType, length: usize )

Writes the header for a map in order to begin writing map values

key_type The type of the map keys value_type The type of the map values length The total number of items that will be written

source

pub fn clear(&mut self)

Clears the contents of the underlying buffer

Trait Implementations§

source§

impl Default for TdfWriter

source§

fn default() -> TdfWriter

Returns the “default value” for a type. Read more
source§

impl From<TdfWriter> for Vec<u8>

Implementation for converting tdf writer into its underlying buffer with from

source§

fn from(value: TdfWriter) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more