pub struct JsonResult<T> {
pub value: T,
pub status: u16,
}Expand description
200 OK + a JSON body — the result the framework uses for ordinary
Serialize DTO responses.
Fields§
§value: TThe value written as application/json.
status: u16HTTP status to use instead of 200.
Implementations§
Source§impl<T> JsonResult<T>
impl<T> JsonResult<T>
Sourcepub fn new(value: T) -> JsonResult<T>
pub fn new(value: T) -> JsonResult<T>
A 200 OK JSON result.
Sourcepub fn status(self, status: u16) -> JsonResult<T>
pub fn status(self, status: u16) -> JsonResult<T>
Override the HTTP status (e.g. 201 after a create).
Trait Implementations§
Source§impl<T> IActionResult for JsonResult<T>
impl<T> IActionResult for JsonResult<T>
Source§fn execute<'life0, 'async_trait>(
self: Box<JsonResult<T>>,
ctx: &'life0 mut dyn IHttpContext,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
JsonResult<T>: 'async_trait,
fn execute<'life0, 'async_trait>(
self: Box<JsonResult<T>>,
ctx: &'life0 mut dyn IHttpContext,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
JsonResult<T>: 'async_trait,
Write this result into the response.
Auto Trait Implementations§
impl<T> Forget for JsonResult<T>
impl<T> Freeze for JsonResult<T>where
T: Freeze,
impl<T> Move for JsonResult<T>
impl<T> RefUnwindSafe for JsonResult<T>where
T: RefUnwindSafe,
impl<T> Send for JsonResult<T>where
T: Send,
impl<T> Sync for JsonResult<T>where
T: Sync,
impl<T> Unpin for JsonResult<T>where
T: Unpin,
impl<T> UnsafeUnpin for JsonResult<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for JsonResult<T>where
T: UnwindSafe,
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