pub struct ResponseBuilder;Expand description
HTTP response builder (suitable for plugin runtime).
Provides the following construction capabilities:
- Success response (JSON).
- Error response (automatic mapping of status codes and structures).
- File stream response (opens files based on host UUID).
- Status code response (pure status code, no body).
Implementations§
Source§impl ResponseBuilder
impl ResponseBuilder
Sourcepub fn json<T: Serialize>(data: &T) -> Response
pub fn json<T: Serialize>(data: &T) -> Response
Constructs a JSON response (200 OK).
鈿狅笍 If serialization fails, [] is returned as fallback content; this does not indicate logic success.
Sourcepub fn error(err: VtxError) -> Response
pub fn error(err: VtxError) -> Response
Constructs an error response (automatically maps HTTP status codes based on error type).
AuthDenied(code)鈫?code(401 / 403)NotFound(_)鈫?404PermissionDenied(_)鈫?403SerializationError(_)鈫?400DatabaseError(_),Internal(_)鈫?500
Return structure:
{
"success": false,
"error": true,
"code": 403,
"type": "PermissionDenied",
"message": "You are not allowed to access this resource"
}Sourcepub fn file(uri: &str) -> Response
pub fn file(uri: &str) -> Response
Constructs a file stream response (opens via host interface by UUID).
- Success: 200 + file content stream.
- Failure: Returns 404 JSON error response.
Auto Trait Implementations§
impl Freeze for ResponseBuilder
impl RefUnwindSafe for ResponseBuilder
impl Send for ResponseBuilder
impl Sync for ResponseBuilder
impl Unpin for ResponseBuilder
impl UnwindSafe for ResponseBuilder
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