pub enum HeaderLayout {
Robot,
Gripper,
}Expand description
Which of the two protocol header layouts a TCP session frames with.
libfranka has one CommandHeader per protocol: the robot’s has a uint32_t command
(research_interface/robot/service_types.h), the gripper’s a uint16_t command
(research_interface/gripper/types.h). The framing code is otherwise identical, so the
Rust crate::network::TcpSession is generic over this enum instead of over a type.
Variants§
Robot
12-byte header: u32 command, u32 command_id, u32 size.
Gripper
10-byte header: u16 command, u32 command_id, u32 size.
Implementations§
Source§impl HeaderLayout
impl HeaderLayout
Sourcepub const fn header_len(self) -> usize
pub const fn header_len(self) -> usize
Size of the header in bytes (12 for the robot, 10 for the gripper).
Sourcepub const fn command_width(self) -> usize
pub const fn command_width(self) -> usize
Width of the leading command field in bytes (4 for the robot, 2 for the gripper).
Sourcepub fn encode_header(
self,
command: u32,
command_id: u32,
payload_len: usize,
) -> Vec<u8> ⓘ
pub fn encode_header( self, command: u32, command_id: u32, payload_len: usize, ) -> Vec<u8> ⓘ
Writes a header for command into a fresh byte vector, reserving room for payload_len.
size counts the header itself, exactly like libfranka’s CommandHeader::size.
Sourcepub fn decode_header(self, buf: &[u8]) -> Option<(u32, u32, u32)>
pub fn decode_header(self, buf: &[u8]) -> Option<(u32, u32, u32)>
Decodes command, command_id and size out of a header-sized prefix of buf.
Returns None when buf is shorter than HeaderLayout::header_len.
Trait Implementations§
Source§impl Clone for HeaderLayout
impl Clone for HeaderLayout
Source§fn clone(&self) -> HeaderLayout
fn clone(&self) -> HeaderLayout
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for HeaderLayout
Source§impl Debug for HeaderLayout
impl Debug for HeaderLayout
impl Eq for HeaderLayout
Source§impl PartialEq for HeaderLayout
impl PartialEq for HeaderLayout
Source§fn eq(&self, other: &HeaderLayout) -> bool
fn eq(&self, other: &HeaderLayout) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for HeaderLayout
Auto Trait Implementations§
impl Freeze for HeaderLayout
impl RefUnwindSafe for HeaderLayout
impl Send for HeaderLayout
impl Sync for HeaderLayout
impl Unpin for HeaderLayout
impl UnsafeUnpin for HeaderLayout
impl UnwindSafe for HeaderLayout
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.