pub struct ProtobufResponse<T>where
T: Message,{ /* private fields */ }Expand description
Protobuf response wrapper
Encodes a Protobuf message and returns it with the correct content type.
§Example
ⓘ
use at_jet::prelude::*;
async fn get_user(Path(id): Path<i32>) -> ProtobufResponse<User> {
let user = User { id, name: "John".to_string() };
ProtobufResponse::ok(user)
}
async fn create_user(
ProtobufRequest(req): ProtobufRequest<CreateUserRequest>
) -> ProtobufResponse<User> {
let user = User { id: 1, name: req.name };
ProtobufResponse::created(user)
}Implementations§
Source§impl<T> ProtobufResponse<T>where
T: Message,
impl<T> ProtobufResponse<T>where
T: Message,
Sourcepub fn new(status: StatusCode, message: T) -> Self
pub fn new(status: StatusCode, message: T) -> Self
Create a new response with custom status code
Trait Implementations§
Source§impl<T> IntoResponse for ProtobufResponse<T>where
T: Message,
impl<T> IntoResponse for ProtobufResponse<T>where
T: Message,
Source§fn into_response(self) -> Response
fn into_response(self) -> Response
Create a response.
Auto Trait Implementations§
impl<T> Freeze for ProtobufResponse<T>where
T: Freeze,
impl<T> RefUnwindSafe for ProtobufResponse<T>where
T: RefUnwindSafe,
impl<T> Send for ProtobufResponse<T>
impl<T> Sync for ProtobufResponse<T>
impl<T> Unpin for ProtobufResponse<T>where
T: Unpin,
impl<T> UnwindSafe for ProtobufResponse<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