FromNative

Trait FromNative 

Source
pub trait FromNative<N>: Sized {
    // Required method
    fn from_native(value: N) -> Self;
}
Expand description

Used to do value-to-value conversions while consuming the input value. It is the reciprocal of IntoProto.

One should always prefer implementing FromNative over IntoProto because implementing FromNative automatically provides one with an implementation of IntoProto thanks to the blanket implementation in this crate.

This can’t failed because every prost type is just a subset of the native one.

§Generic Implementations

  • FromNative<T> for U implies IntoProto<U> for T

You should probabily use the derive macro to impl FromNative<P>

Required Methods§

Source

fn from_native(value: N) -> Self

Performs the conversion.

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.

Implementations on Foreign Types§

Source§

impl FromNative<IpAddr> for String

Source§

fn from_native(value: IpAddr) -> Self

Source§

impl FromNative<SocketAddr> for String

Source§

fn from_native(value: SocketAddr) -> Self

Source§

impl FromNative<bool> for bool

Source§

fn from_native(value: bool) -> Self

Source§

impl FromNative<f32> for f32

Source§

fn from_native(value: f32) -> Self

Source§

impl FromNative<f64> for f64

Source§

fn from_native(value: f64) -> Self

Source§

impl FromNative<i8> for i32

Source§

fn from_native(value: i8) -> Self

Source§

impl FromNative<i16> for i32

Source§

fn from_native(value: i16) -> Self

Source§

impl FromNative<i32> for i32

Source§

fn from_native(value: i32) -> Self

Source§

impl FromNative<i64> for i64

Source§

fn from_native(value: i64) -> Self

Source§

impl FromNative<u8> for u32

Source§

fn from_native(value: u8) -> Self

Source§

impl FromNative<u16> for u32

Source§

fn from_native(value: u16) -> Self

Source§

impl FromNative<u32> for u32

Source§

fn from_native(value: u32) -> Self

Source§

impl FromNative<u64> for u64

Source§

fn from_native(value: u64) -> Self

Source§

impl FromNative<()> for ()

Source§

fn from_native(_: ()) -> Self

Source§

impl FromNative<String> for String

Source§

fn from_native(value: String) -> Self

Source§

impl FromNative<Vec<u8>> for Vec<u8>

Source§

fn from_native(value: Vec<u8>) -> Self

Source§

impl FromNative<Ipv4Addr> for String

Source§

fn from_native(value: Ipv4Addr) -> Self

Source§

impl FromNative<Ipv6Addr> for String

Source§

fn from_native(value: Ipv6Addr) -> Self

Source§

impl FromNative<PathBuf> for String

Source§

fn from_native(value: PathBuf) -> Self

Source§

impl FromNative<Uuid> for String

Source§

fn from_native(value: Uuid) -> Self

Source§

impl<T, U> FromNative<Vec<U>> for Vec<T>
where T: FromNative<U>,

Source§

fn from_native(value: Vec<U>) -> Self

Source§

impl<T, U> FromNative<HashMap<bool, U>> for HashMap<bool, T>
where T: FromNative<U>,

Source§

fn from_native(value: HashMap<bool, U>) -> Self

Source§

impl<T, U> FromNative<HashMap<i32, U>> for HashMap<i32, T>
where T: FromNative<U>,

Source§

fn from_native(value: HashMap<i32, U>) -> Self

Source§

impl<T, U> FromNative<HashMap<i64, U>> for HashMap<i64, T>
where T: FromNative<U>,

Source§

fn from_native(value: HashMap<i64, U>) -> Self

Source§

impl<T, U> FromNative<HashMap<u32, U>> for HashMap<u32, T>
where T: FromNative<U>,

Source§

fn from_native(value: HashMap<u32, U>) -> Self

Source§

impl<T, U> FromNative<HashMap<u64, U>> for HashMap<u64, T>
where T: FromNative<U>,

Source§

fn from_native(value: HashMap<u64, U>) -> Self

Source§

impl<T, U> FromNative<HashMap<String, U>> for HashMap<String, T>
where T: FromNative<U>,

Source§

fn from_native(value: HashMap<String, U>) -> Self

Source§

impl<T, U> FromNative<U> for Option<T>
where T: FromNative<U>,

Source§

fn from_native(value: U) -> Self

Implementors§