Capability to modify CAN frame data without copying. #4075
This commit is contained in:
parent
8fb0186f87
commit
4d903a713e
@ -128,6 +128,11 @@ impl ClassicData {
|
|||||||
pub fn raw(&self) -> &[u8] {
|
pub fn raw(&self) -> &[u8] {
|
||||||
&self.bytes
|
&self.bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Raw mutable read access to data.
|
||||||
|
pub fn raw_mut(&mut self) -> &mut [u8] {
|
||||||
|
&mut self.bytes
|
||||||
|
}
|
||||||
|
|
||||||
/// Checks if the length can be encoded in FDCAN DLC field.
|
/// Checks if the length can be encoded in FDCAN DLC field.
|
||||||
pub const fn is_valid_len(len: usize) -> bool {
|
pub const fn is_valid_len(len: usize) -> bool {
|
||||||
@ -208,6 +213,11 @@ impl Frame {
|
|||||||
pub fn data(&self) -> &[u8] {
|
pub fn data(&self) -> &[u8] {
|
||||||
&self.data.raw()
|
&self.data.raw()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get mutable reference to data
|
||||||
|
pub fn data_mut(&mut self) -> &mut [u8] {
|
||||||
|
self.data.raw_mut()
|
||||||
|
}
|
||||||
|
|
||||||
/// Get priority of frame
|
/// Get priority of frame
|
||||||
pub fn priority(&self) -> u32 {
|
pub fn priority(&self) -> u32 {
|
||||||
@ -313,6 +323,11 @@ impl FdData {
|
|||||||
pub fn raw(&self) -> &[u8] {
|
pub fn raw(&self) -> &[u8] {
|
||||||
&self.bytes
|
&self.bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Raw mutable read access to data.
|
||||||
|
pub fn raw_mut(&mut self) -> &mut [u8] {
|
||||||
|
&mut self.bytes
|
||||||
|
}
|
||||||
|
|
||||||
/// Checks if the length can be encoded in FDCAN DLC field.
|
/// Checks if the length can be encoded in FDCAN DLC field.
|
||||||
pub const fn is_valid_len(len: usize) -> bool {
|
pub const fn is_valid_len(len: usize) -> bool {
|
||||||
@ -392,6 +407,11 @@ impl FdFrame {
|
|||||||
pub fn data(&self) -> &[u8] {
|
pub fn data(&self) -> &[u8] {
|
||||||
&self.data.raw()
|
&self.data.raw()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get mutable reference to data
|
||||||
|
pub fn data_mut(&mut self) -> &mut [u8] {
|
||||||
|
self.data.raw_mut()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl embedded_can::Frame for FdFrame {
|
impl embedded_can::Frame for FdFrame {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user