pub struct Optional;
Expand description
Namespace for functions that perform encoding of Option
values.
Implementations§
Source§impl Optional
impl Optional
Sourcepub fn read<R: Read, T, F>(reader: R, func: F) -> Result<Option<T>>
pub fn read<R: Read, T, F>(reader: R, func: F) -> Result<Option<T>>
Reads an optional value, assuming the encoding written by Optional::write
, using the
provided function to decode the contained element if present.
Sourcepub fn write<W: Write, T, F>(writer: W, val: Option<T>, func: F) -> Result<()>
pub fn write<W: Write, T, F>(writer: W, val: Option<T>, func: F) -> Result<()>
Writes an optional value to a stream by writing a flag byte with a value of 0 if no value is present, or 1 if there is a value, followed by the encoding of the contents of the option as performed by the provided function.
Auto Trait Implementations§
impl Freeze for Optional
impl RefUnwindSafe for Optional
impl Send for Optional
impl Sync for Optional
impl Unpin for Optional
impl UnwindSafe for Optional
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more