pub struct RpcMessage<T, P>{ /* private fields */ }Expand description
An Open Network Computing RPC message, generic over a source of bytes (T)
and a payload buffer (P).
Implementations§
Source§impl<'a> RpcMessage<&'a [u8], &'a [u8]>
impl<'a> RpcMessage<&'a [u8], &'a [u8]>
Sourcepub fn from_bytes(buf: &'a [u8]) -> Result<Self, Error>
👎Deprecated since 0.3.0: prefer the TryFrom impl instead
pub fn from_bytes(buf: &'a [u8]) -> Result<Self, Error>
TryFrom impl insteadDeserialises a new RpcMessage from buf.
Buf must contain exactly 1 message - if buf contains an incomplete
message, or buf contains trailing bytes after the message
Error::IncompleteMessage is returned.
Source§impl<T, P> RpcMessage<T, P>
impl<T, P> RpcMessage<T, P>
Sourcepub fn new(xid: u32, message_type: MessageType<T, P>) -> Self
pub fn new(xid: u32, message_type: MessageType<T, P>) -> Self
Construct a new RpcMessage with the specified transaction ID and
message body.
Sourcepub fn serialise_into<W: Write>(&self, buf: W) -> Result<(), Error>
pub fn serialise_into<W: Write>(&self, buf: W) -> Result<(), Error>
Write this RpcMessage into buf, advancing the cursor to the end of
the serialised message. buf must have capacity for at least
RpcMessage::serialised_len() bytes from the current cursor position.
This method allows the caller to specify the underlying buffer used to hold the serialised message to enable reuse and pooling.
Sourcepub fn serialise(&self) -> Result<Vec<u8>, Error>
pub fn serialise(&self) -> Result<Vec<u8>, Error>
Serialise this RpcMessage into a new Vec.
The returned vec will be sized exactly to contain this message. Calling this method is the equivalent of:
let mut buf = Vec::with_capacity(msg.serialised_len() as usize);
let mut c = Cursor::new(buf);
msg.serialise_into(&mut c);Sourcepub fn serialised_len(&self) -> u32
pub fn serialised_len(&self) -> u32
Returns the on-wire length of this message once serialised, including the message header.
Sourcepub fn message(&self) -> &MessageType<T, P>
pub fn message(&self) -> &MessageType<T, P>
The MessageType contained in this request.
Sourcepub fn call_body(&self) -> Option<&CallBody<T, P>>
pub fn call_body(&self) -> Option<&CallBody<T, P>>
Returns the CallBody in this request, or None if this message is
not a RPC call request.
Sourcepub fn reply_body(&self) -> Option<&ReplyBody<T, P>>
pub fn reply_body(&self) -> Option<&ReplyBody<T, P>>
Returns the ReplyBody in this request, or None if this message is
not a RPC response.
Trait Implementations§
Source§impl<T, P> Debug for RpcMessage<T, P>
impl<T, P> Debug for RpcMessage<T, P>
Source§impl<T, P> PartialEq for RpcMessage<T, P>
impl<T, P> PartialEq for RpcMessage<T, P>
Source§impl<'a> TryFrom<&'a [u8]> for RpcMessage<&'a [u8], &'a [u8]>
impl<'a> TryFrom<&'a [u8]> for RpcMessage<&'a [u8], &'a [u8]>
Source§fn try_from(v: &'a [u8]) -> Result<Self, Self::Error>
fn try_from(v: &'a [u8]) -> Result<Self, Self::Error>
Deserialises a new RpcMessage from buf.
Buf must contain exactly 1 message - if buf contains an incomplete
message, or buf contains trailing bytes after the message
Error::IncompleteMessage is returned.