Trait nix_compat::wire::ser::NixWrite
source · pub trait NixWrite: Send {
type Error: Error;
// Required methods
fn version(&self) -> ProtocolVersion;
fn write_number(
&mut self,
value: u64,
) -> impl Future<Output = Result<(), Self::Error>> + Send;
fn write_slice(
&mut self,
buf: &[u8],
) -> impl Future<Output = Result<(), Self::Error>> + Send;
// Provided methods
fn write_display<D>(
&mut self,
msg: D,
) -> impl Future<Output = Result<(), Self::Error>> + Send
where D: Display + Send,
Self: Sized { ... }
fn write_value<V>(
&mut self,
value: &V,
) -> impl Future<Output = Result<(), Self::Error>> + Send
where V: NixSerialize + Send + ?Sized,
Self: Sized { ... }
}
Required Associated Types§
Required Methods§
sourcefn version(&self) -> ProtocolVersion
fn version(&self) -> ProtocolVersion
Some types are serialized differently depending on the version of the protocol and so this can be used for implementing that.
Provided Methods§
sourcefn write_display<D>(
&mut self,
msg: D,
) -> impl Future<Output = Result<(), Self::Error>> + Send
fn write_display<D>( &mut self, msg: D, ) -> impl Future<Output = Result<(), Self::Error>> + Send
Write a value that implements std::fmt::Display
to the protocol.
The protocol uses many small string formats and instead of allocating
a String
each time we want to write one an implementation of NixWrite
can instead use Display
to dump these formats to a reusable buffer.
Object Safety§
This trait is not object safe.