Skip to main content

ProstCodec

Struct ProstCodec 

Source
pub struct ProstCodec<E, D> { /* private fields */ }
Expand description

Encodes E and decodes D as individual Protobuf payloads.

The directions may use different message types, as is usual for RPC requests and responses. The adapter holds no message data between calls; callers may reuse both the codec and the outbound buffer across messages.

Implementations§

Source§

impl<E, D> ProstCodec<E, D>

Source

pub const CONTENT_TYPE: &'static str = "application/grpc"

HTTP content type emitted for Protobuf messages.

Source

pub const fn new() -> ProstCodec<E, D>

Creates a codec for the specified outbound and inbound message types.

Source

pub fn accepts_content_type(content_type: &str) -> bool

Accepts the default gRPC media type and its explicit Protobuf variant.

Media types are compared case-insensitively, ignoring surrounding HTTP whitespace and optional media type parameters.

Trait Implementations§

Source§

impl<E, D> Codec for ProstCodec<E, D>
where E: Message, D: Message + Default,

Source§

const CONTENT_TYPE: &'static str = Self::CONTENT_TYPE

HTTP content type identifying this serialization format.
Source§

type EncodeItem = E

Message type accepted by the encoder.
Source§

type DecodeItem = D

Owned message type returned by the decoder.
Source§

type Error = ProstCodecError

Serialization or deserialization failure.
Source§

fn encode( &mut self, item: &E, destination: &mut Vec<u8>, ) -> Result<(), <ProstCodec<E, D> as Codec>::Error>

Appends one serialized message to destination. Read more
Source§

fn decode( &mut self, payload: &[u8], ) -> Result<D, <ProstCodec<E, D> as Codec>::Error>

Decodes exactly one message payload. Read more
Source§

impl<E, D> Debug for ProstCodec<E, D>
where E: Debug, D: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<E, D> Default for ProstCodec<E, D>

Source§

fn default() -> ProstCodec<E, D>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<E, D> Freeze for ProstCodec<E, D>
where PhantomData<fn(E) -> D>: Freeze,

§

impl<E, D> RefUnwindSafe for ProstCodec<E, D>
where PhantomData<fn(E) -> D>: RefUnwindSafe,

§

impl<E, D> Send for ProstCodec<E, D>
where PhantomData<fn(E) -> D>: Send,

§

impl<E, D> Sync for ProstCodec<E, D>
where PhantomData<fn(E) -> D>: Sync,

§

impl<E, D> Unpin for ProstCodec<E, D>
where PhantomData<fn(E) -> D>: Unpin,

§

impl<E, D> UnsafeUnpin for ProstCodec<E, D>
where PhantomData<fn(E) -> D>: UnsafeUnpin,

§

impl<E, D> UnwindSafe for ProstCodec<E, D>
where PhantomData<fn(E) -> D>: UnwindSafe,

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> Same for T

Source§

type Output = T

Should always be Self
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.