Struct someip_parse::TpBufConfig
source · pub struct TpBufConfig {
pub tp_buffer_start_payload_alloc_len: usize,
/* private fields */
}
Expand description
Configuration of a TP buffers maximum allowed size and initial allocated buffer size.
Fields§
§tp_buffer_start_payload_alloc_len: usize
Number of bytes that should be allocated to store payload
when a new TpBuf
gets created.
Implementations§
source§impl TpBufConfig
impl TpBufConfig
sourcepub const MAX_TP_PAYLOAD_LEN: u32 = 4_294_967_279u32
pub const MAX_TP_PAYLOAD_LEN: u32 = 4_294_967_279u32
Maximum representable payload len in a TP packet.
This is determined by the maximum value the length field in the SOMEIP header can take - 8 bytes
sourcepub fn tp_max_payload_len(&self) -> u32
pub fn tp_max_payload_len(&self) -> u32
Maximum allowed payload length (in bytes) of the final reconstructed packet.
sourcepub fn new(
tp_buffer_start_payload_alloc_len: usize,
tp_max_payload_len: u32
) -> Result<TpBufConfig, TpBufConfigError>
pub fn new( tp_buffer_start_payload_alloc_len: usize, tp_max_payload_len: u32 ) -> Result<TpBufConfig, TpBufConfigError>
Creates a new config with the given initial allocated and maximum allowed payload size.
Example
As long as you don’t set the max_payload_len to more then
TpBufConfig::MAX_TP_PAYLOAD_LEN
(0xFFFFFFFF - 16):
use someip_parse::TpBufConfig;
let config = TpBufConfig::new(
// start alloc size
1024,
// maximum allowed size
// (if you have knowledge about the maximum message size,
// insert that here and above)
TpBufConfig::MAX_TP_PAYLOAD_LEN
).unwrap();
construction will only fail if you set an upper lenght greater
then TpBufConfig::MAX_TP_PAYLOAD_LEN
:
use someip_parse::{TpBufConfig, err::TpBufConfigError::*};
assert_eq!(
TpBufConfig::new(1024, TpBufConfig::MAX_TP_PAYLOAD_LEN + 1),
Err(MaxPayloadLenTooBig{
allowed_max: TpBufConfig::MAX_TP_PAYLOAD_LEN,
actual: TpBufConfig::MAX_TP_PAYLOAD_LEN + 1,
})
);
Trait Implementations§
source§impl Clone for TpBufConfig
impl Clone for TpBufConfig
source§fn clone(&self) -> TpBufConfig
fn clone(&self) -> TpBufConfig
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for TpBufConfig
impl Debug for TpBufConfig
source§impl Default for TpBufConfig
impl Default for TpBufConfig
source§impl Hash for TpBufConfig
impl Hash for TpBufConfig
source§impl Ord for TpBufConfig
impl Ord for TpBufConfig
source§fn cmp(&self, other: &TpBufConfig) -> Ordering
fn cmp(&self, other: &TpBufConfig) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for TpBufConfig
impl PartialEq for TpBufConfig
source§fn eq(&self, other: &TpBufConfig) -> bool
fn eq(&self, other: &TpBufConfig) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for TpBufConfig
impl PartialOrd for TpBufConfig
source§fn partial_cmp(&self, other: &TpBufConfig) -> Option<Ordering>
fn partial_cmp(&self, other: &TpBufConfig) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Eq for TpBufConfig
impl StructuralEq for TpBufConfig
impl StructuralPartialEq for TpBufConfig
Auto Trait Implementations§
impl RefUnwindSafe for TpBufConfig
impl Send for TpBufConfig
impl Sync for TpBufConfig
impl Unpin for TpBufConfig
impl UnwindSafe for TpBufConfig
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