pub trait Argdata<'d>: Sync {
Show 14 methods
// Required methods
fn serialize(
&self,
writer: &mut dyn Write,
fd_map: Option<&mut dyn FdMapping>,
) -> Result<()>;
fn serialized_length(&self) -> usize;
// Provided methods
fn read<'a>(&'a self) -> Result<Value<'a, 'd>, ReadError>
where 'd: 'a { ... }
fn get_type(&self) -> Result<Type, ReadError> { ... }
fn read_null(&self) -> Result<(), NotRead> { ... }
fn read_binary(&self) -> Result<&'d [u8], NotRead> { ... }
fn read_bool(&self) -> Result<bool, NotRead> { ... }
fn read_encoded_fd<'a>(
&'a self,
) -> Result<EncodedFd<&'a dyn ConvertFd>, NotRead>
where 'd: 'a { ... }
fn read_float(&self) -> Result<f64, NotRead> { ... }
fn read_int_value(&self) -> Result<IntValue<'d>, NotRead> { ... }
fn read_map<'a>(&'a self) -> Result<MapIterator<'a, 'd>, NotRead>
where 'd: 'a { ... }
fn read_seq<'a>(&'a self) -> Result<SeqIterator<'a, 'd>, NotRead>
where 'd: 'a { ... }
fn read_str_value(&self) -> Result<StrValue<'d>, NotRead> { ... }
fn read_timestamp(&self) -> Result<Timespec, NotRead> { ... }
}Expand description
An argdata value.
Note for implementers of this trait: Although all read methods have provided implementations, they are implemented in terms of eachother. You either need to provide:
- the
read()method, or - the
get_type()method and implementations of allread_*()methods.
Do the latter if read() would do anything non-trivial, to keep things efficient.
get_type() and read_*() need to be consistent, which means that read_$TYPE() for the type
returned by get_type() may not return an Err(NotRead::NoFit). Otherwise, read() will
panic.
Required Methods§
Sourcefn serialize(
&self,
writer: &mut dyn Write,
fd_map: Option<&mut dyn FdMapping>,
) -> Result<()>
fn serialize( &self, writer: &mut dyn Write, fd_map: Option<&mut dyn FdMapping>, ) -> Result<()>
Serialize the argdata to the given writer.
Exactly self.serialized_bytes() bytes are written to the writer, if no error occurs.
File descriptors are mapped using fd_map.
If it is None, encoded file descriptors will be kept as is, and actual
file descriptors will be encoded as -1 (invalid).
Sourcefn serialized_length(&self) -> usize
fn serialized_length(&self) -> usize
The number of bytes that self.serialize() will write.
Provided Methods§
Sourcefn read_binary(&self) -> Result<&'d [u8], NotRead>
fn read_binary(&self) -> Result<&'d [u8], NotRead>
Check if the value is a binary blob, and read it if it is.
Sourcefn read_bool(&self) -> Result<bool, NotRead>
fn read_bool(&self) -> Result<bool, NotRead>
Check if the value is a boolean, and read it if it is.
Sourcefn read_encoded_fd<'a>(
&'a self,
) -> Result<EncodedFd<&'a dyn ConvertFd>, NotRead>where
'd: 'a,
fn read_encoded_fd<'a>(
&'a self,
) -> Result<EncodedFd<&'a dyn ConvertFd>, NotRead>where
'd: 'a,
Check if the value is a file descriptor, and return it if it is.
Even though this function succeeds (returns an Ok()), converting the returned EncodedFd
to an Fd might still fail.
Note: You probably want to use read_fd instead.
Sourcefn read_float(&self) -> Result<f64, NotRead>
fn read_float(&self) -> Result<f64, NotRead>
Check if the value is a float, and read it if it is.
Sourcefn read_int_value(&self) -> Result<IntValue<'d>, NotRead>
fn read_int_value(&self) -> Result<IntValue<'d>, NotRead>
Check if the value is an integer, and read it if it is.
Note: You might want to use read_int instead to
directly get a primitive type like i32 or u64.
Sourcefn read_map<'a>(&'a self) -> Result<MapIterator<'a, 'd>, NotRead>where
'd: 'a,
fn read_map<'a>(&'a self) -> Result<MapIterator<'a, 'd>, NotRead>where
'd: 'a,
Check if the value is a map, and get an iterator over it if it is.
Sourcefn read_seq<'a>(&'a self) -> Result<SeqIterator<'a, 'd>, NotRead>where
'd: 'a,
fn read_seq<'a>(&'a self) -> Result<SeqIterator<'a, 'd>, NotRead>where
'd: 'a,
Check if the value is a seq, and get an iterator over it if it is.
Sourcefn read_str_value(&self) -> Result<StrValue<'d>, NotRead>
fn read_str_value(&self) -> Result<StrValue<'d>, NotRead>
Check if the value is a string, and read it if it is.
Note: You probably want to use read_str instead
to directly get a &str.
Sourcefn read_timestamp(&self) -> Result<Timespec, NotRead>
fn read_timestamp(&self) -> Result<Timespec, NotRead>
Check if the value is a timestamp, and read it if it is.