pub struct ApiResponse<T> {
pub success: bool,
pub data: Option<T>,
pub error: Option<ApiErrorBody>,
pub trace_id: Option<String>,
}Expand description
API 响应结构
用于标准化 API 响应格式。
Fields§
§success: bool是否成功
data: Option<T>响应数据
error: Option<ApiErrorBody>错误信息
trace_id: Option<String>追踪 ID
Implementations§
Source§impl<T: Serialize> ApiResponse<T>
impl<T: Serialize> ApiResponse<T>
Sourcepub fn into_response(self) -> Response<Body>
pub fn into_response(self) -> Response<Body>
将 API 响应转换为 HTTP 响应
Trait Implementations§
Source§impl<T: Debug> Debug for ApiResponse<T>
impl<T: Debug> Debug for ApiResponse<T>
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