[−][src]Struct libmctp::smbus::MCTPSMBusContext
The global context for MCTP SMBus operations
Implementations
impl<'m> MCTPSMBusContext<'m>
[src]
pub fn new(
address: u8,
msg_types: &'m [u8],
vendor_ids: &'m [VendorIDFormat]
) -> Self
[src]
address: u8,
msg_types: &'m [u8],
vendor_ids: &'m [VendorIDFormat]
) -> Self
Create a new SBMust context
address
: The source address of this device.
pub fn get_request(&self) -> &MCTPSMBusContextRequest
[src]
Get the underlying request protocol struct. This can be used to manually generate specific packets
pub fn get_response(&self) -> &MCTPSMBusContextResponse
[src]
Get the underlying response protocol struct. This can be used to manually generate specific packets
pub fn set_uuid(&mut self, uuid: &[u8])
[src]
Set the Unique Identifier for this device
pub fn decode_packet<'a>(
&self,
packet: &'a [u8]
) -> Result<(MessageType, &'a [u8]), (MessageType, DecodeError)>
[src]
&self,
packet: &'a [u8]
) -> Result<(MessageType, &'a [u8]), (MessageType, DecodeError)>
Decodes a MCTP packet.
packet
: A buffer of the packet to get the headers from.
On success returns the MessageType
and a reference into packet
where
the payload starts.
On error returned the MessageType
and a DecodeError
.
pub fn get_length(
&self,
packet: &[u8]
) -> Result<usize, (MessageType, DecodeError)>
[src]
&self,
packet: &[u8]
) -> Result<usize, (MessageType, DecodeError)>
Get the length of a packet
This function will just return the total byte count of the SMBus packet. This function purposely does almost no checks so that it can be run on a partial packet to determine how many bytes to read from a bus.
When returning the length the length is the byte count from the packet plus four. This is because the byte count does not include the "destination slave address", "command code", "byte count" or PEC. This means it's the total number of bytes in the entire packet.
packet
: A buffer of the packet to get the headers from.
On success returns the usize
with the total length of the packet
based on the length of the command code.
On error returned the MessageType
and a DecodeError
.
pub fn process_packet<'a, 'b>(
&self,
packet: &'a [u8],
response_buf: &'b mut [u8]
) -> Result<((MessageType, &'a [u8]), Option<usize>), (MessageType, DecodeError)>
[src]
&self,
packet: &'a [u8],
response_buf: &'b mut [u8]
) -> Result<((MessageType, &'a [u8]), Option<usize>), (MessageType, DecodeError)>
This function first decodes the packet supplied in the packet
argument.
This is done using the decode_packet()
function.
If this packet is a request then the response_buf
is populated with
a response to the request.
packet
: A buffer of the packet to get the headers from.
On success the first two arguments are the same as
the return from the decode_packet()
function. The third argument is
an option. If None
then response_buf
wasn't changed because the
packet
was not a request. If Some
it contains the length of the
data written in the response_buf
.
Auto Trait Implementations
impl<'m> Send for MCTPSMBusContext<'m>
impl<'m> !Sync for MCTPSMBusContext<'m>
impl<'m> Unpin for MCTPSMBusContext<'m>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,