pub struct TpHeader {
pub more_segment: bool,
/* private fields */
}Expand description
Additional header when a packet contains a TP header (transporting large SOME/IP messages).
Fields§
§more_segment: boolFlag signaling that more packets should follow
Implementations§
Source§impl TpHeader
impl TpHeader
Sourcepub fn new(more_segment: bool) -> TpHeader
pub fn new(more_segment: bool) -> TpHeader
Creates a tp header with offset 0 and the given “move_segment” flag.
§Example:
use someip_parse::TpHeader;
// create a header with the more_segement flag set
let header = TpHeader::new(true);
assert_eq!(0, header.offset());
assert_eq!(true, header.more_segment);Sourcepub fn with_offset(
offset: u32,
more_segment: bool,
) -> Result<TpHeader, TpOffsetNotMultipleOf16Error>
pub fn with_offset( offset: u32, more_segment: bool, ) -> Result<TpHeader, TpOffsetNotMultipleOf16Error>
Creates a tp header with the given offset & “more_segment” flag if the offset is a multiple of 16. Otherwise an TpOffsetNotMultipleOf16 error is returned.
§Example:
use someip_parse::{TpHeader, err::TpOffsetNotMultipleOf16Error};
// create a header with offset 32 (multiple of 16) and the more_segement flag set
let header = TpHeader::with_offset(32, true).unwrap();
assert_eq!(32, header.offset());
assert_eq!(true, header.more_segment);
// try to create a header with a bad offset (non multiple of 16)
let error = TpHeader::with_offset(31, false);
assert_eq!(Err(TpOffsetNotMultipleOf16Error{ bad_offset: 31 }), error);Sourcepub fn set_offset(
&mut self,
offset: u32,
) -> Result<(), TpOffsetNotMultipleOf16Error>
pub fn set_offset( &mut self, offset: u32, ) -> Result<(), TpOffsetNotMultipleOf16Error>
Sets the field of the header and returns Ok(()) on success. Note: The value must be a multiple of 16.
If the given value is not a multiple of 16, the value is not set and an error err::TpOffsetNotMultipleOf16Error is returned.
Sourcepub fn read<T: Read>(reader: &mut T) -> Result<TpHeader, Error>
pub fn read<T: Read>(reader: &mut T) -> Result<TpHeader, Error>
Read a header from a byte stream.
Sourcepub fn read_from_slice(slice: &[u8]) -> Result<TpHeader, LenError>
pub fn read_from_slice(slice: &[u8]) -> Result<TpHeader, LenError>
Reads a tp header from a slice.
Sourcepub unsafe fn from_slice_unchecked(slice: &[u8]) -> TpHeader
pub unsafe fn from_slice_unchecked(slice: &[u8]) -> TpHeader
Read the value from the slice without checking for the minimum length of the slice.
§Safety
It is required that the slice has at least the length of TP_HEADER_LENGTH (4 octets/bytes). If this is not the case undefined behavior will occur.
Sourcepub fn write<T: Write>(&self, writer: &mut T) -> Result<(), Error>
pub fn write<T: Write>(&self, writer: &mut T) -> Result<(), Error>
Writes the header to the given writer.
Sourcepub fn write_to_slice(
&self,
slice: &mut [u8],
) -> Result<(), SliceWriteSpaceError>
pub fn write_to_slice( &self, slice: &mut [u8], ) -> Result<(), SliceWriteSpaceError>
Writes the header to a slice.
Trait Implementations§
impl Eq for TpHeader
impl StructuralPartialEq for TpHeader
Auto Trait Implementations§
impl Freeze for TpHeader
impl RefUnwindSafe for TpHeader
impl Send for TpHeader
impl Sync for TpHeader
impl Unpin for TpHeader
impl UnwindSafe for TpHeader
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)