Struct gotham_restful::Raw
source · [−]pub struct Raw<T> {
pub raw: T,
pub mime: Mime,
}
Expand description
This type can be used both as a raw request body, as well as as a raw response. However, all types of request bodies are accepted by this type. It is therefore recommended to derive your own type from RequestBody and only use this when you need to return a raw response. This is a usage example that simply returns its body:
#[derive(Resource)]
#[resource(create)]
struct ImageResource;
#[create]
fn create(body: Raw<Vec<u8>>) -> Raw<Vec<u8>> {
body
}
Fields
raw: T
mime: Mime
Implementations
Trait Implementations
sourceimpl<T: for<'a> From<&'a [u8]>> FromBody for Raw<T>
impl<T: for<'a> From<&'a [u8]>> FromBody for Raw<T>
type Err = Infallible
type Err = Infallible
The error type returned by the conversion if it was unsuccessfull. When using the derive
macro, there is no way to trigger an error, so std::convert::Infallible is used here.
However, this might change in the future. Read more
sourceimpl<T: Into<Body>> IntoResponse for Raw<T>where
Self: Send,
impl<T: Into<Body>> IntoResponse for Raw<T>where
Self: Send,
type Err = Error
sourcefn into_response(
self
) -> Pin<Box<dyn Future<Output = Result<Response, SerdeJsonError>> + Send>>
fn into_response(
self
) -> Pin<Box<dyn Future<Output = Result<Response, SerdeJsonError>> + Send>>
Turn this into a response that can be returned to the browser. This api will likely
change in the future. Read more
sourcefn accepted_types() -> Option<Vec<Mime>>
fn accepted_types() -> Option<Vec<Mime>>
Return a list of supported mime types.
sourceimpl<T> OpenapiType for Raw<T>
impl<T> OpenapiType for Raw<T>
fn visit_type<V: Visitor>(visitor: &mut V)
fn schema() -> OpenapiSchema
sourceimpl<T> RequestBody for Raw<T>where
Raw<T>: FromBody + ResourceType,
impl<T> RequestBody for Raw<T>where
Raw<T>: FromBody + ResourceType,
sourcefn supported_types() -> Option<Vec<Mime>>
fn supported_types() -> Option<Vec<Mime>>
Return all types that are supported as content types. Use
None
if all types are supported.sourceimpl<T: Into<Body>> ResponseSchema for Raw<T>where
Self: Send,
impl<T: Into<Body>> ResponseSchema for Raw<T>where
Self: Send,
sourcefn schema(code: StatusCode) -> OpenapiSchema
fn schema(code: StatusCode) -> OpenapiSchema
Return the schema of the response for the given status code. The code may
only be one that was previously returned by Self::status_codes. The
implementation should panic if that is not the case. Read more
sourcefn status_codes() -> Vec<StatusCode>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
fn status_codes() -> Vec<StatusCode>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A>where
A: Allocator,
A: Allocator,
All status codes returned by this response. Returns
[StatusCode::OK]
by default.Auto Trait Implementations
impl<T> RefUnwindSafe for Raw<T>where
T: RefUnwindSafe,
impl<T> Send for Raw<T>where
T: Send,
impl<T> Sync for Raw<T>where
T: Sync,
impl<T> Unpin for Raw<T>where
T: Unpin,
impl<T> UnwindSafe for Raw<T>where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> IntoSql for T
impl<T> IntoSql for T
sourcefn into_sql<T>(self) -> Self::Expressionwhere
Self: AsExpression<T> + Sized,
T: SqlType + TypedExpressionType,
fn into_sql<T>(self) -> Self::Expressionwhere
Self: AsExpression<T> + Sized,
T: SqlType + TypedExpressionType,
Convert
self
to an expression for Diesel’s query builder. Read moresourcefn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
&'a Self: AsExpression<T>,
T: SqlType + TypedExpressionType,
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere
&'a Self: AsExpression<T>,
T: SqlType + TypedExpressionType,
Convert
&self
to an expression for Diesel’s query builder. Read more