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));
}Tag Value Format ↩
Required Methods§
Sourcefn get_string(&self, id: usize) -> Result<Cow<'_, String>, TvfError>
fn get_string(&self, id: usize) -> Result<Cow<'_, String>, TvfError>
Get a string value from a TVF
Sourcefn get_bytes(&self, id: usize) -> Result<Cow<'_, Bytes>, TvfError>
fn get_bytes(&self, id: usize) -> Result<Cow<'_, Bytes>, TvfError>
Get a buffer of bytes from a TVF
Sourcefn get_datetime(&self, id: usize) -> Result<NaiveDateTime, TvfError>
fn get_datetime(&self, id: usize) -> Result<NaiveDateTime, TvfError>
Get a datetime field from a TVF.
The timestamp is considered to be UTC.
Sourcefn put_buffer(&mut self, id: usize, buffer: Self)where
Self: Tvf,
fn put_buffer(&mut self, id: usize, buffer: Self)where
Self: Tvf,
Put a buffer as sub field into a TVF
Sourcefn put_unsigned(&mut self, id: usize, unsigned: u64)
fn put_unsigned(&mut self, id: usize, unsigned: u64)
Put an unsigned value to a TVF
Sourcefn put_signed(&mut self, id: usize, signed: i64)
fn put_signed(&mut self, id: usize, signed: i64)
Put a signed value to a TVF
Sourcefn put_string<T: Into<String>>(&mut self, id: usize, string: T)
fn put_string<T: Into<String>>(&mut self, id: usize, string: T)
Put a string value to a TVF
Sourcefn put_datetime(&mut self, id: usize, datetime: NaiveDateTime)
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§
impl Tvf for SimpleStringTvf
TVF implementation of simple string TVF