pub trait NewTypeAdapter {
    type StandardType;
    type AdaptedType;
}
Expand description

Convenience trait for newtype adapters.

This trait simplifies construction of adapters that newtype the standard type. On top of the standard bounds, the newtype (adapted type) needs to also have a From and Into implementation for the standard thrift type.

Examples

use fbthrift::adapter::NewTypeAdapter;

#[derive(Clone, Debug)]
struct MyInt(i64);

impl From<MyInt> for i64 {
    fn from(v: MyInt) -> Self { v.0 }
}

impl From<i64> for MyInt {
    fn from(v: i64) -> Self { Self(v) }
}

struct MyIntAdapter;

impl NewTypeAdapter for MyIntAdapter {
    type StandardType = i64;
    type AdaptedType = MyInt;
}

Required Associated Types§

source

type StandardType

The thrift type that the adapter interprets.

source

type AdaptedType

The Rust type to adapt to.

Implementors§