pub struct LoadBalancingOption<T: AsRef<[u8]>> { /* private fields */ }Expand description
Zero-copy wrapper around Load Balancing Option (8 bytes total: 4 header + 4 data).
Load balancing options provide priority and weight values for server selection.
Wire format (8 bytes):
0 1 2 3
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Length | Type |D| Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Priority | Weight |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+Implementations§
Source§impl<T: AsRef<[u8]>> LoadBalancingOption<T>
impl<T: AsRef<[u8]>> LoadBalancingOption<T>
Sourcepub const LENGTH: usize = 8usize
pub const LENGTH: usize = 8usize
Load balancing option wire format size in bytes (4 header + 4 data).
Sourcepub fn new_unchecked(buffer: T) -> Self
pub fn new_unchecked(buffer: T) -> Self
Sourcepub fn new_checked(buffer: T) -> Result<Self>
pub fn new_checked(buffer: T) -> Result<Self>
Sourcepub fn check_len(&self) -> Result<()>
pub fn check_len(&self) -> Result<()>
Validate that the buffer is at least 8 bytes long.
§Returns
Ok(())if buffer meets minimum length requirementErr(Error)if buffer is too short
Sourcepub fn header(&self) -> OptionHeader<&[u8]>
pub fn header(&self) -> OptionHeader<&[u8]>
Get a view of the option header (first 4 bytes).
§Returns
OptionHeader wrapper around the header bytes
Source§impl<T: AsRef<[u8]> + AsMut<[u8]>> LoadBalancingOption<T>
impl<T: AsRef<[u8]> + AsMut<[u8]>> LoadBalancingOption<T>
Sourcepub fn set_priority(&mut self, priority: u16)
pub fn set_priority(&mut self, priority: u16)
Set the priority value (2 bytes at offset 4-5, network byte order).
§Parameters
priority- Priority value (lower is higher priority)
Sourcepub fn set_weight(&mut self, weight: u16)
pub fn set_weight(&mut self, weight: u16)
Set the weight value (2 bytes at offset 6-7, network byte order).
§Parameters
weight- Weight value for load distribution
Trait Implementations§
Source§impl<T: Clone + AsRef<[u8]>> Clone for LoadBalancingOption<T>
impl<T: Clone + AsRef<[u8]>> Clone for LoadBalancingOption<T>
Source§fn clone(&self) -> LoadBalancingOption<T>
fn clone(&self) -> LoadBalancingOption<T>
Returns a duplicate 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 moreimpl<T: Copy + AsRef<[u8]>> Copy for LoadBalancingOption<T>
Auto Trait Implementations§
impl<T> Freeze for LoadBalancingOption<T>where
T: Freeze,
impl<T> RefUnwindSafe for LoadBalancingOption<T>where
T: RefUnwindSafe,
impl<T> Send for LoadBalancingOption<T>where
T: Send,
impl<T> Sync for LoadBalancingOption<T>where
T: Sync,
impl<T> Unpin for LoadBalancingOption<T>where
T: Unpin,
impl<T> UnwindSafe for LoadBalancingOption<T>where
T: UnwindSafe,
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