Struct onc_rpc::RpcMessage

source ·
pub struct RpcMessage<T, P>
where T: AsRef<[u8]>, P: AsRef<[u8]>,
{ /* 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]>

source

pub fn from_bytes(buf: &'a [u8]) -> Result<Self, Error>

👎Deprecated since 0.3.0: prefer the TryFrom impl instead

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.

source§

impl<T, P> RpcMessage<T, P>
where T: AsRef<[u8]>, P: AsRef<[u8]>,

source

pub fn new(xid: u32, message_type: MessageType<T, P>) -> Self

Construct a new RpcMessage with the specified transaction ID and message body.

source

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.

source

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);
source

pub fn serialised_len(&self) -> u32

Returns the on-wire length of this message once serialised, including the message header.

source

pub fn xid(&self) -> u32

The transaction ID for this request.

source

pub fn message(&self) -> &MessageType<T, P>

The MessageType contained in this request.

source

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.

source

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>
where T: AsRef<[u8]> + Debug, P: AsRef<[u8]> + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T, P> PartialEq for RpcMessage<T, P>
where T: AsRef<[u8]> + PartialEq, P: AsRef<[u8]> + PartialEq,

source§

fn eq(&self, other: &RpcMessage<T, P>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> TryFrom<&'a [u8]> for RpcMessage<&'a [u8], &'a [u8]>

source§

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.

§

type Error = Error

The type returned in the event of a conversion error.
source§

impl TryFrom<Bytes> for RpcMessage<Bytes, Bytes>

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(v: Bytes) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, P> StructuralPartialEq for RpcMessage<T, P>
where T: AsRef<[u8]>, P: AsRef<[u8]>,

Auto Trait Implementations§

§

impl<T, P> Freeze for RpcMessage<T, P>
where P: Freeze, T: Freeze,

§

impl<T, P> RefUnwindSafe for RpcMessage<T, P>

§

impl<T, P> Send for RpcMessage<T, P>
where P: Send, T: Send,

§

impl<T, P> Sync for RpcMessage<T, P>
where P: Sync, T: Sync,

§

impl<T, P> Unpin for RpcMessage<T, P>
where P: Unpin, T: Unpin,

§

impl<T, P> UnwindSafe for RpcMessage<T, P>
where P: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.