Skip to main content

Tvf

Trait Tvf 

Source
pub trait Tvf {
Show 24 methods // Required methods fn is_empty(&self) -> bool; fn len(&self) -> usize; fn contains(&self, id: usize) -> bool; fn remove(&mut self, id: usize); fn into_keys(self) -> Vec<usize>; fn keys(&self) -> Vec<usize>; fn get_buffer(&self, id: usize) -> Result<Cow<'_, Self>, TvfError> where Self: Tvf + Clone; fn get_unsigned(&self, id: usize) -> Result<u64, TvfError>; fn get_signed(&self, id: usize) -> Result<i64, TvfError>; fn get_byte(&self, id: usize) -> Result<u8, TvfError>; fn get_float(&self, id: usize) -> Result<f64, TvfError>; fn get_string(&self, id: usize) -> Result<Cow<'_, String>, TvfError>; fn get_bytes(&self, id: usize) -> Result<Cow<'_, Bytes>, TvfError>; fn get_date(&self, id: usize) -> Result<NaiveDate, TvfError>; fn get_datetime(&self, id: usize) -> Result<NaiveDateTime, TvfError>; fn put_buffer(&mut self, id: usize, buffer: Self) where Self: Tvf; fn put_unsigned(&mut self, id: usize, unsigned: u64); fn put_signed(&mut self, id: usize, signed: i64); fn put_byte(&mut self, id: usize, byte: u8); fn put_float(&mut self, id: usize, float: f64); fn put_string<T: Into<String>>(&mut self, id: usize, string: T); fn put_bytes(&mut self, id: usize, buffer: Bytes); fn put_date(&mut self, id: usize, date: NaiveDate); fn put_datetime(&mut self, id: usize, datetime: NaiveDateTime);
}
Available on crate feature msg only.
Expand description

Trait that define a TVF1 Use to define a key/value object that structure a data

use prosa_utils::msg::tvf::Tvf;

fn sample<T: Tvf>(mut tvf: T) {
    tvf.put_string(1, "toto");
    assert!(tvf.contains(1));
    assert_eq!("toto", tvf.get_string(1).unwrap().as_str());

    tvf.remove(1);
    assert!(!tvf.contains(1));
}

  1. Tag Value Format 

Required Methods§

Source

fn is_empty(&self) -> bool

Method to know if the TVF is empty

Source

fn len(&self) -> usize

Method to know the number of field in the TVF (not recursive)

Source

fn contains(&self, id: usize) -> bool

Method to know is the TVF contain a field the id key

Source

fn remove(&mut self, id: usize)

Method to remove a TVF field

Source

fn into_keys(self) -> Vec<usize>

Method to convert the TVF into vector ok keys

Source

fn keys(&self) -> Vec<usize>

Get all the keys for this TVF

Source

fn get_buffer(&self, id: usize) -> Result<Cow<'_, Self>, TvfError>
where Self: Tvf + Clone,

Get a sub buffer from a TVF

Source

fn get_unsigned(&self, id: usize) -> Result<u64, TvfError>

Get an unsigned value from a TVF

Source

fn get_signed(&self, id: usize) -> Result<i64, TvfError>

Get a signed value from a TVF

Source

fn get_byte(&self, id: usize) -> Result<u8, TvfError>

Get a byte value from a TVF

Source

fn get_float(&self, id: usize) -> Result<f64, TvfError>

Get a float value from a TVF

Source

fn get_string(&self, id: usize) -> Result<Cow<'_, String>, TvfError>

Get a string value from a TVF

Source

fn get_bytes(&self, id: usize) -> Result<Cow<'_, Bytes>, TvfError>

Get a buffer of bytes from a TVF

Source

fn get_date(&self, id: usize) -> Result<NaiveDate, TvfError>

Get a date field from a TVF

Source

fn get_datetime(&self, id: usize) -> Result<NaiveDateTime, TvfError>

Get a datetime field from a TVF.
The timestamp is considered to be UTC.

Source

fn put_buffer(&mut self, id: usize, buffer: Self)
where Self: Tvf,

Put a buffer as sub field into a TVF

Source

fn put_unsigned(&mut self, id: usize, unsigned: u64)

Put an unsigned value to a TVF

Source

fn put_signed(&mut self, id: usize, signed: i64)

Put a signed value to a TVF

Source

fn put_byte(&mut self, id: usize, byte: u8)

Put a byte into a TVF

Source

fn put_float(&mut self, id: usize, float: f64)

Put a float value to a TVF

Source

fn put_string<T: Into<String>>(&mut self, id: usize, string: T)

Put a string value to a TVF

Source

fn put_bytes(&mut self, id: usize, buffer: Bytes)

Put some bytes into a TVF

Source

fn put_date(&mut self, id: usize, date: NaiveDate)

Put a date into a TVF

Source

fn put_datetime(&mut self, id: usize, datetime: NaiveDateTime)

Put a datetime into a TVF.
The timestamp is considered to be UTC.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Tvf for SimpleStringTvf

TVF implementation of simple string TVF