pub struct Context<'a, S: Serializer + 'a> { /* private fields */ }Expand description
Context available when serializing the response.
Implementations§
Source§impl<'a, S> Context<'a, S>where
S: Serializer,
impl<'a, S> Context<'a, S>where
S: Serializer,
Sourcepub fn new(request: &'a Request<()>, serializer: &'a S) -> Context<'a, S>
pub fn new(request: &'a Request<()>, serializer: &'a S) -> Context<'a, S>
Create a new response context.
Sourcepub fn serialize<T>(
&self,
value: &T,
context: &SerializerContext<'_>,
) -> Result<Bytes, Error>where
T: Serialize,
pub fn serialize<T>(
&self,
value: &T,
context: &SerializerContext<'_>,
) -> Result<Bytes, Error>where
T: Serialize,
Serialize a value.
This uses the default content type for the action.
Returns an error when a default content type is not set.
Sourcepub fn serialize_as<T>(
&self,
_value: &T,
_content_type: &str,
) -> Result<Bytes, Error>where
T: Serialize,
pub fn serialize_as<T>(
&self,
_value: &T,
_content_type: &str,
) -> Result<Bytes, Error>where
T: Serialize,
Serialize a value as the specified content type.
Sourcepub fn content_type_header(&self) -> Option<&HeaderValue>
pub fn content_type_header(&self) -> Option<&HeaderValue>
Returns a HeaderValue representation of the default content type.
Trait Implementations§
Auto Trait Implementations§
impl<'a, S> Freeze for Context<'a, S>
impl<'a, S> !RefUnwindSafe for Context<'a, S>
impl<'a, S> Send for Context<'a, S>
impl<'a, S> Sync for Context<'a, S>
impl<'a, S> Unpin for Context<'a, S>
impl<'a, S> !UnwindSafe for Context<'a, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more