Struct MctpLinuxEp

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

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

Implementations§

Source§

impl MctpLinuxEp

Source

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

Create a new MCTPEndpoint with EID eid

Examples found in repository?
examples/mctp-req.rs (line 15)
11fn main() -> std::io::Result<()> {
12    const EID : u8 = 8;
13
14    // Create a new endpoint using the linux socket support
15    let mut ep = MctpLinuxEp::new(EID, MCTP_NET_ANY)?;
16
17    // for subsequent use of `ep`, we're just interacting with the
18    // mctp::Endpoint trait, which are 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, Tag::OwnedAuto, &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 (rx_buf, eid, tag) = ep.recv(&mut rx_buf)?;
29
30    println!("response from {}, tag {}: {:x?}", eid, tag, rx_buf);
31
32    Ok(())
33}
Source

pub fn try_clone(&self) -> Result<Self>

Clone this endpoint.

Creates a separate socket descriptor for the new endpoint.

Source

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

Borrow the internal MCTP socket

Trait Implementations§

Source§

impl Endpoint for MctpLinuxEp

Source§

fn bind(&mut self, typ: MsgType) -> Result<()>

Bind the endpoint’s socket to a type value, so we can receive incoming requests from this endpoint.

Note that this only specifies the local EID for the bind; there can only be one bind of that type for any one network.

Source§

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

Send a message to this endpoint, blocking. Read more
Source§

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

Blocking recieve from this endpoint. Read more
Source§

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

Send a message to this endpoint, blocking.

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.