Skip to main content

ServiceRequest

Struct ServiceRequest 

Source
pub struct ServiceRequest<T: Message> {
    pub uri: Uri,
    pub method: Method,
    pub version: Version,
    pub headers: HeaderMap,
    pub input: T,
}
Expand description

A request with HTTP info and a proto request payload object.

Fields§

§uri: Uri

The URI of the original request

When using a client, this will be overridden with the proper URI. It is only valuable for servers.

§method: Method

The request method; should always be POST.

§version: Version

The HTTP version, rarely changed from the default.

§headers: HeaderMap

The set of headers

Should always at least have Content-Type. Clients will override Content-Length on serialization.

§input: T

The request body as a proto Message, representing the arguments of the proto rpc.

Implementations§

Source§

impl<T: Message> ServiceRequest<T>

Source

pub fn new(input: T) -> ServiceRequest<T>

Create new service request with the given input object

This automatically sets the Content-Type header as application/protobuf.

Source

pub fn clone_with_input(&self, input: T) -> ServiceRequest<T>

Copy this request with a different input value

Source§

impl<T: Message + Default + 'static> ServiceRequest<T>

Source

pub fn to_hyper_request(&self) -> Result<Request<Body>, ProstTwirpError>

Serialize into a hyper request.

Source

pub async fn from_hyper_request( req: Request<Body>, ) -> Result<ServiceRequest<T>, ProstTwirpError>

Trait Implementations§

Source§

impl<T: Debug + Message> Debug for ServiceRequest<T>

Source§

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

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

impl<T: Message + Default + 'static> From<T> for ServiceRequest<T>

Source§

fn from(v: T) -> ServiceRequest<T>

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T> !Freeze for ServiceRequest<T>

§

impl<T> RefUnwindSafe for ServiceRequest<T>
where T: RefUnwindSafe,

§

impl<T> Send for ServiceRequest<T>

§

impl<T> Sync for ServiceRequest<T>

§

impl<T> Unpin for ServiceRequest<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for ServiceRequest<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for ServiceRequest<T>
where T: 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more