pub struct ContentResult { /* private fields */ }Expand description
A body sent as-is with an explicit media type — ASP.NET Core’s
ContentResult (Content(...), Text(...), Results.Bytes(...)).
Implementations§
Source§impl ContentResult
impl ContentResult
Sourcepub fn text(body: impl Into<String>) -> ContentResult
pub fn text(body: impl Into<String>) -> ContentResult
UTF-8 text/plain; charset=utf-8.
Sourcepub fn html(body: impl Into<String>) -> ContentResult
pub fn html(body: impl Into<String>) -> ContentResult
UTF-8 text/html; charset=utf-8.
Sourcepub fn bytes(
body: impl Into<Vec<u8>>,
content_type: impl Into<String>,
) -> ContentResult
pub fn bytes( body: impl Into<Vec<u8>>, content_type: impl Into<String>, ) -> ContentResult
Raw bytes with an explicit media type.
Sourcepub fn content_type(self, content_type: impl Into<String>) -> ContentResult
pub fn content_type(self, content_type: impl Into<String>) -> ContentResult
Override the media type (e.g. text/csv; charset=utf-8).
Sourcepub fn status(self, status: u16) -> ContentResult
pub fn status(self, status: u16) -> ContentResult
Override the HTTP status.
Sourcepub fn header(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> ContentResult
pub fn header( self, key: impl Into<String>, value: impl Into<String>, ) -> ContentResult
Add a response header.
Sourcepub fn download_name(self, file_name: impl Into<String>) -> ContentResult
pub fn download_name(self, file_name: impl Into<String>) -> ContentResult
Send the body as a download named file_name
(Content-Disposition: attachment).
Sourcepub fn inline_name(self, file_name: impl Into<String>) -> ContentResult
pub fn inline_name(self, file_name: impl Into<String>) -> ContentResult
Send the body inline under file_name
(Content-Disposition: inline).
Trait Implementations§
Source§impl IActionResult for ContentResult
impl IActionResult for ContentResult
Source§fn execute<'life0, 'async_trait>(
self: Box<ContentResult>,
ctx: &'life0 mut dyn IHttpContext,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
ContentResult: 'async_trait,
fn execute<'life0, 'async_trait>(
self: Box<ContentResult>,
ctx: &'life0 mut dyn IHttpContext,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
ContentResult: 'async_trait,
Write this result into the response.
Auto Trait Implementations§
impl Forget for ContentResult
impl Freeze for ContentResult
impl Move for ContentResult
impl RefUnwindSafe for ContentResult
impl Send for ContentResult
impl Sync for ContentResult
impl Unpin for ContentResult
impl UnsafeUnpin for ContentResult
impl UnwindSafe for ContentResult
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