Struct NixWrite

Source
pub struct NixWrite<W> {
    pub inner: W,
}
Expand description

A wrapper around a std::io::Write, adding support for the nix wire format.

Fields§

§inner: W

Implementations§

Source§

impl<W: Write> NixWrite<W>

Source

pub fn write_u64(&mut self, n: u64) -> Result<()>

Write an integer to the wire.

Source

pub fn write_string(&mut self, s: &[u8]) -> Result<()>

Write a “string” (really, a byte buffer) to the wire.

Source

pub fn write_nix(&mut self, data: &impl Serialize) -> Result<()>

Write any serializable type to the wire.

Warning: don’t call this with [u8] data: that will (attempt to) serialize a sequence of u8s, and then panic because the nix wire protocol only supports 64-bit integers. If you want to write a byte buffer, use NixWrite::write_string instead.

Source

pub fn flush(&mut self) -> Result<()>

Flush the underlying writer.

Auto Trait Implementations§

§

impl<W> Freeze for NixWrite<W>
where W: Freeze,

§

impl<W> RefUnwindSafe for NixWrite<W>
where W: RefUnwindSafe,

§

impl<W> Send for NixWrite<W>
where W: Send,

§

impl<W> Sync for NixWrite<W>
where W: Sync,

§

impl<W> Unpin for NixWrite<W>
where W: Unpin,

§

impl<W> UnwindSafe for NixWrite<W>
where W: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.