pub struct ApiResponse<T> {
pub success: bool,
pub data: Option<T>,
pub error: Option<ApiErrorBody>,
pub trace_id: Option<String>,
}Expand description
统一 JSON 响应结构
Fields§
§success: bool是否成功
data: Option<T>响应数据
error: Option<ApiErrorBody>错误信息
trace_id: Option<String>请求追踪 ID
Implementations§
Source§impl<T> ApiResponse<T>where
T: Serialize,
impl<T> ApiResponse<T>where
T: Serialize,
Sourcepub fn success_with_trace(data: T, trace_id: impl Into<String>) -> Self
pub fn success_with_trace(data: T, trace_id: impl Into<String>) -> Self
创建成功响应(带追踪 ID)
Trait Implementations§
Source§impl<T: Debug> Debug for ApiResponse<T>
impl<T: Debug> Debug for ApiResponse<T>
Source§impl<T: Serialize> IntoResponse for ApiResponse<T>
impl<T: Serialize> IntoResponse for ApiResponse<T>
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Create a response.
Auto Trait Implementations§
impl<T> Freeze for ApiResponse<T>where
T: Freeze,
impl<T> RefUnwindSafe for ApiResponse<T>where
T: RefUnwindSafe,
impl<T> Send for ApiResponse<T>where
T: Send,
impl<T> Sync for ApiResponse<T>where
T: Sync,
impl<T> Unpin for ApiResponse<T>where
T: Unpin,
impl<T> UnsafeUnpin for ApiResponse<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for ApiResponse<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