Trait npyz::TypeWrite

source ·
pub trait TypeWrite {
    type Value: ?Sized;

    // Required method
    fn write_one<W: Write>(&self, writer: W, value: &Self::Value) -> Result<()>
       where Self: Sized;
}
Expand description

Like some sort of for<W: io::Write> Fn(W, &T) -> io::Result<()>.

To obtain one of these, use the Serialize trait.

For an example of how to implement this manually, see Vector5 in the roundtrip test.

Trait objects

dyn TypeWrite has no object-safe methods. If you need dynamic polymorphism, use dyn TypeWriteDyn instead.

Required Associated Types§

source

type Value: ?Sized

Type accepted by the function.

Required Methods§

source

fn write_one<W: Write>(&self, writer: W, value: &Self::Value) -> Result<()>
where Self: Sized,

The function.

Implementations on Foreign Types§

source§

impl<T: ?Sized> TypeWrite for Box<dyn TypeWriteDyn<Value = T>>

§

type Value = T

source§

fn write_one<W: Write>(&self, writer: W, value: &T) -> Result<()>
where Self: Sized,

Implementors§