pub enum ApiJson<T> {
Data {
code: Option<Cow<'static, str>>,
data: Option<T>,
},
Error {
code: Option<Cow<'static, str>>,
error: Option<Cow<'static, str>>,
},
}Expand description
Standard Api response formatter.
Variants§
Implementations§
source§impl<T: Serialize> ApiJson<T>
impl<T: Serialize> ApiJson<T>
pub fn ok(data: T) -> Self
pub fn data_with_code(data: T, code: Cow<'static, str>) -> Self
pub fn error_builder() -> ApiJsonErrorBuilder<T>
source§impl ApiJson<()>
impl ApiJson<()>
sourcepub fn unit_error_builder() -> ApiJsonErrorBuilder<()>
pub fn unit_error_builder() -> ApiJsonErrorBuilder<()>
Convenience method to build error without specifying generic type parameter
pub fn no_content() -> Self
pub const fn default_error() -> Self
Trait Implementations§
Auto Trait Implementations§
impl<T> RefUnwindSafe for ApiJson<T>where
T: RefUnwindSafe,
impl<T> Send for ApiJson<T>where
T: Send,
impl<T> Sync for ApiJson<T>where
T: Sync,
impl<T> Unpin for ApiJson<T>where
T: Unpin,
impl<T> UnwindSafe for ApiJson<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