Trait FromRefForWriter

Source
pub trait FromRefForWriter<'a> {
    type Inner: ?Sized;
    type Wr: WriteTo + 'a;

    // Required method
    fn from_ref_for_writer(value: &'a Self::Inner) -> Self::Wr;
}
Expand description

Trait to use when using the with_newtype attribute.

This is used to convert a reference to a normal type (like String, Vec<u8> etc. into a type that is a reference to them, like &str, &[u8] etc.), so that the WriteTo implementation can be written only for the reference types, and all the other WriteTo impls will only cast what they have to write to those reference types (via the function below), and then call the WriteTo::write_to method on that reference.

Required Associated Types§

Source

type Inner: ?Sized

The inner type to cast.

Source

type Wr: WriteTo + 'a

The reference type to cast to.

Required Methods§

Source

fn from_ref_for_writer(value: &'a Self::Inner) -> Self::Wr

Casts the reference to the inner type to a WriteTo reference type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a> FromRefForWriter<'a> for FileBytes

Source§

impl<'a> FromRefForWriter<'a> for FileString

Source§

impl<'a, T> FromRefForWriter<'a> for Json<T>
where T: Serialize + for<'d> Deserialize<'d> + 'static,

Available on crate feature json only.
Source§

type Inner = T

Source§

type Wr = JsonRefWr<'a, T>

Source§

impl<'a, T> FromRefForWriter<'a> for Ron<T>
where T: Serialize + for<'d> Deserialize<'d> + 'static,

Available on crate feature ron only.
Source§

type Inner = T

Source§

type Wr = RonRefWr<'a, T>

Source§

impl<'a, T> FromRefForWriter<'a> for CleanDir<T>
where T: DirStructureItem + 'a,

Source§

type Inner = T

Source§

type Wr = CleanDirRefWr<'a, T>

Source§

impl<'a, T> FromRefForWriter<'a> for FmtWrapper<T>
where T: Display + 'a,

Source§

impl<'a, T> FromRefForWriter<'a> for Toml<T>
where T: Serialize + for<'d> Deserialize<'d> + 'static,

Available on crate feature toml only.
Source§

type Inner = T

Source§

type Wr = TomlRefWr<'a, T>

Source§

impl<'a, T> FromRefForWriter<'a> for Yaml<T>
where T: Serialize + for<'d> Deserialize<'d> + 'static,

Available on crate feature yaml only.
Source§

type Inner = T

Source§

type Wr = YamlRefWr<'a, T>