Struct MctpLinuxReq

Source
pub struct MctpLinuxReq { /* private fields */ }
Expand description

Encapsulation of a remote endpoint: a socket and an Endpoint ID.

Implementations§

Source§

impl MctpLinuxReq

Source

pub fn new(eid: Eid, net: Option<u32>) -> Result<Self>

Create a new MctpLinuxReq with EID eid

Examples found in repository?
examples/mctp-req.rs (line 15)
11fn main() -> std::io::Result<()> {
12    const EID: Eid = Eid(8);
13
14    // Create a new endpoint using the linux socket support
15    let mut ep = MctpLinuxReq::new(EID, None)?;
16
17    // for subsequent use of `ep`, we're just interacting with the
18    // mctp::ReqChannel trait, which is independent of the socket support
19
20    // Get Endpoint ID message: command 0x02, no data. Allow the MCTP stack
21    // to allocate an owned tag.
22    let tx_buf = vec![0x02u8];
23    ep.send(MCTP_TYPE_CONTROL, &tx_buf)?;
24
25    // Receive a response. We create a 16-byte vec to read into; ep.recv()
26    // will return the sub-slice containing just the response data.
27    let mut rx_buf = vec![0u8; 16];
28    let (typ, ic, rx_buf) = ep.recv(&mut rx_buf)?;
29
30    println!("response type {}, ic {:?}: {:x?}", typ, ic, rx_buf);
31
32    Ok(())
33}
Source

pub fn as_socket(&mut self) -> &mut MctpSocket

Borrow the internal MCTP socket

Source

pub fn net(&self) -> Option<u32>

Returns the MCTP Linux network, or None for the default MCTP_NET_ANY

Trait Implementations§

Source§

impl ReqChannel for MctpLinuxReq

Source§

fn send_vectored( &mut self, typ: MsgType, ic: MsgIC, bufs: &[&[u8]], ) -> Result<()>

Send a MCTP message

Linux MCTP can also send a preallocated owned tag, but that is not yet supported in MctpLinuxReq.

Source§

fn recv<'f>( &mut self, buf: &'f mut [u8], ) -> Result<(MsgType, MsgIC, &'f mut [u8])>

Blocking receive Read more
Source§

fn remote_eid(&self) -> Eid

Return the remote Endpoint ID
Source§

fn send(&mut self, typ: MsgType, buf: &[u8]) -> Result<(), Error>

Send a message to this endpoint, blocking. Read more

Auto Trait Implementations§

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>,

Source§

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>,

Source§

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.