LoadBalancingOption

Struct LoadBalancingOption 

Source
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>

Source

pub const LENGTH: usize = 8usize

Load balancing option wire format size in bytes (4 header + 4 data).

Source

pub fn new_unchecked(buffer: T) -> Self

Create a LoadBalancingOption without validation.

§Parameters
  • buffer - The buffer containing the 8-byte option
§Safety

This does not validate buffer length. Use new_checked for validation.

Source

pub fn new_checked(buffer: T) -> Result<Self>

Create a LoadBalancingOption from a buffer with length validation.

§Parameters
  • buffer - The buffer containing the 8-byte option
§Returns
  • Ok(LoadBalancingOption) if buffer is at least 8 bytes
  • Err(Error) if buffer is too short
Source

pub fn check_len(&self) -> Result<()>

Validate that the buffer is at least 8 bytes long.

§Returns
  • Ok(()) if buffer meets minimum length requirement
  • Err(Error) if buffer is too short
Source

pub fn header(&self) -> OptionHeader<&[u8]>

Get a view of the option header (first 4 bytes).

§Returns

OptionHeader wrapper around the header bytes

Source

pub fn priority(&self) -> u16

Get the priority value (2 bytes at offset 4-5, network byte order).

§Returns

Priority value (lower is higher priority)

Source

pub fn weight(&self) -> u16

Get the weight value (2 bytes at offset 6-7, network byte order).

§Returns

Weight value for load distribution

Source§

impl<T: AsRef<[u8]> + AsMut<[u8]>> LoadBalancingOption<T>

Source

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)
Source

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>

Source§

fn clone(&self) -> LoadBalancingOption<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + AsRef<[u8]>> Debug for LoadBalancingOption<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.