pub struct Message {
pub cmd_id: CommandId,
pub request_id: String,
pub payload: Option<Bytes>,
}
Expand description
The unit of the protocol built on top of TCP that this server uses.
Fields§
§cmd_id: CommandId
Used as a way of identifying the format of the payload for deserialization
request_id: String
A unique request identifier - used for request tracing and debugging Note that this has to be encoded as utf8 otherwise parsing the message will fail
payload: Option<Bytes>
the Request payload
Implementations§
Source§impl Message
impl Message
Sourcepub fn new(
cmd_id: CommandId,
request_id: String,
payload: Option<Bytes>,
) -> Self
pub fn new( cmd_id: CommandId, request_id: String, payload: Option<Bytes>, ) -> Self
Constructs a new Message
with the given id and payload
Sourcepub async fn try_from_async_read<R: AsyncRead + Unpin>(
reader: &mut R,
) -> Result<Self>
pub async fn try_from_async_read<R: AsyncRead + Unpin>( reader: &mut R, ) -> Result<Self>
This function tries to construct a Message
by reading bytes from the provided AsyncRead
source
§Errors
This functions returns errors in the following cases
- The message size is bigger than
MAX_MESSAGE_SIZE
- The message is somehow malformed (eg: less bytes were provided than the length received)
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request