Skip to main content

Codec

Struct Codec 

Source
pub struct Codec<A, R> {
    pub decode: fn(Value) -> Result<A, String>,
    pub encode: fn(R) -> Result<Value, String>,
}
Expand description

How a method bound with Service::method_with reads its portable arguments and writes its result, in place of serde, so its Rust types need no serde implementation.

Fields§

§decode: fn(Value) -> Result<A, String>

Read the arguments’ JSON, or refuse it with a message: the call then fails with Reason::Arguments before its callback runs.

§encode: fn(R) -> Result<Value, String>

Write the result as JSON, or refuse it with a message: the call then fails with Reason::Result.

Auto Trait Implementations§

§

impl<A, R> Forget for Codec<A, R>

§

impl<A, R> Freeze for Codec<A, R>
where fn(Value) -> Result<A, String>: Freeze, fn(R) -> Result<Value, String>: Freeze,

§

impl<A, R> Move for Codec<A, R>

§

impl<A, R> RefUnwindSafe for Codec<A, R>

§

impl<A, R> Send for Codec<A, R>
where fn(Value) -> Result<A, String>: Send, fn(R) -> Result<Value, String>: Send,

§

impl<A, R> Sync for Codec<A, R>
where fn(Value) -> Result<A, String>: Sync, fn(R) -> Result<Value, String>: Sync,

§

impl<A, R> Unpin for Codec<A, R>
where fn(Value) -> Result<A, String>: Unpin, fn(R) -> Result<Value, String>: Unpin,

§

impl<A, R> UnsafeUnpin for Codec<A, R>

§

impl<A, R> UnwindSafe for Codec<A, R>

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.