[][src]Struct tower_web_protobuf::Proto

pub struct Proto<M: MessagePlus>(pub M);

A wrapper struct for a protobuf message type.

This has to exist because impl<T> Trait for T requires T to be 'covered' by a local type (i.e. Proto), when Self is used (I think). Self is used by Extract (Future: ExtractFuture<Item = Self>) which I think is why:

This example deliberately fails to compile
impl<M, B: BufStream> Extract<B> for M
where
    M: 'static + Message + MessageWrapper<M>
{
    type Future = Immediate<M>;
}

doesn't work.

Niko's excellent blog post has a full writeup.

The effect of this is that you'll have to specify Proto instead of just Message in your functions within impl_web!(). This, in turn hurts testability (you have to wrap your Messages to pass them into the endpoint functions) and kind of works counter to the PORTs (plain old Rust types) philosophy. But, I'm pretty sure it's the best we can do without using macros or modifying tower-web.

Into for Proto and From for Proto are implemented to ease the pain a little bit. Into for Proto instead of From<Proto> for M for the same reasons we aren't just implementing Extract for M.

Deref is also implemented it should be possible to use Proto as an M for most everything.

Implementations

impl<M: MessagePlus> Proto<M>[src]

pub fn move_inner(self) -> M[src]

Unwraps the message (of type M) from it's Proto container, consuming the container in the process.

pub fn new(message: M) -> Self[src]

Creates a new Proto instance from a message of type M.

Trait Implementations

impl<M: MessagePlus> AsRef<M> for Proto<M>[src]

impl<M: MessagePlus + Clone> Clone for Proto<M>[src]

impl<M: MessagePlus + Debug> Debug for Proto<M>[src]

impl<M: MessagePlus> Default for Proto<M>[src]

impl<M: MessagePlus> Deref for Proto<M>[src]

type Target = M

The resulting type after dereferencing.

impl<B, M> Extract<B> for Proto<M> where
    B: BufStream,
    M: 'static + MessagePlus
[src]

type Future = MessageFuture<B, M>

The future representing the completion of the extraction logic.

impl<M: MessagePlus> From<M> for Proto<M>[src]

impl<M> Response for Proto<M> where
    M: MessagePlus
[src]

type Buf = Cursor<Bytes>

Data chunk type.

type Body = BytesWrapper

The HTTP response body type.

Auto Trait Implementations

impl<M> RefUnwindSafe for Proto<M> where
    M: RefUnwindSafe

impl<M> Send for Proto<M>

impl<M> Sync for Proto<M>

impl<M> Unpin for Proto<M> where
    M: Unpin

impl<M> UnwindSafe for Proto<M> where
    M: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<!> for T[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.