pub struct MctpLinuxReq { /* private fields */ }
Expand description
Encapsulation of a remote endpoint: a socket and an Endpoint ID.
Implementations§
Source§impl MctpLinuxReq
impl MctpLinuxReq
Sourcepub fn new(eid: Eid, net: Option<u32>) -> Result<Self>
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}
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 ReqChannel for MctpLinuxReq
impl ReqChannel for MctpLinuxReq
Source§fn send_vectored(
&mut self,
typ: MsgType,
ic: MsgIC,
bufs: &[&[u8]],
) -> Result<()>
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])>
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
fn remote_eid(&self) -> Eid
Return the remote Endpoint ID
Auto Trait Implementations§
impl Freeze for MctpLinuxReq
impl RefUnwindSafe for MctpLinuxReq
impl Send for MctpLinuxReq
impl Sync for MctpLinuxReq
impl Unpin for MctpLinuxReq
impl UnwindSafe for MctpLinuxReq
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