pub struct MctpLinuxEp { /* private fields */ }
Expand description
Encapsulation of a remote endpoint: a socket and an Endpoint ID.
Implementations§
Source§impl MctpLinuxEp
impl MctpLinuxEp
Sourcepub fn new(eid: u8, net: u32) -> Result<Self>
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}
Sourcepub fn try_clone(&self) -> Result<Self>
pub fn try_clone(&self) -> Result<Self>
Clone this endpoint.
Creates a separate socket descriptor for the new endpoint.
Sourcepub fn as_socket(&mut self) -> &mut MctpSocket
pub fn as_socket(&mut self) -> &mut MctpSocket
Borrow the internal MCTP socket
Trait Implementations§
Source§impl Endpoint for MctpLinuxEp
impl Endpoint for MctpLinuxEp
Source§fn bind(&mut self, typ: MsgType) -> Result<()>
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<()>
fn send_vectored( &mut self, typ: MsgType, tag: Tag, bufs: &[&[u8]], ) -> Result<()>
Send a message to this endpoint, blocking. Read more
Auto Trait Implementations§
impl Freeze for MctpLinuxEp
impl RefUnwindSafe for MctpLinuxEp
impl Send for MctpLinuxEp
impl Sync for MctpLinuxEp
impl Unpin for MctpLinuxEp
impl UnwindSafe for MctpLinuxEp
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