pub struct ClientCookie(_);
Expand description
A client cookie for DNS cookies.
The client cookies consists of exactly 8 octets. It is generated by a client for each server it sends queries to. It is important to use a different cookie for every server so a server cannot spoof answers for other servers.
Originally, it was suggested to include the client’s IP address when
generating the cookie, but since the address may not be known when
originating a request, this has been relaxed and it is now suggested that
the cookies is just random data. If the rand
feature is enabled, the
new
new_random
constructor can be used to generate such a random cookie. Otherwise,
it needs to be created from the octets via
from_octets
. Similarly, the Default
implementation will create a random cookie and is thus only available if
the rand
feature is enabled.
Implementations§
source§impl ClientCookie
impl ClientCookie
sourcepub const fn from_octets(octets: [u8; 8]) -> Self
pub const fn from_octets(octets: [u8; 8]) -> Self
Creates a new client cookie from the given octets.
sourcepub fn new_random() -> Self
pub fn new_random() -> Self
Creates a new random client cookie.
sourcepub fn into_octets(self) -> [u8; 8]
pub fn into_octets(self) -> [u8; 8]
Converts the cookie into its octets.
sourcepub fn parse<Octs: AsRef<[u8]> + ?Sized>(
parser: &mut Parser<'_, Octs>
) -> Result<Self, ParseError>
pub fn parse<Octs: AsRef<[u8]> + ?Sized>( parser: &mut Parser<'_, Octs> ) -> Result<Self, ParseError>
Parses a client cookie from its wire format.
sourcepub const COMPOSE_LEN: u16 = 8u16
pub const COMPOSE_LEN: u16 = 8u16
The length of the wire format of a client cookie.
sourcepub fn compose<Target: OctetsBuilder + ?Sized>(
&self,
target: &mut Target
) -> Result<(), Target::AppendError>
pub fn compose<Target: OctetsBuilder + ?Sized>( &self, target: &mut Target ) -> Result<(), Target::AppendError>
Appends the wire format of the client cookie to the target.
Trait Implementations§
source§impl AsMut<[u8]> for ClientCookie
impl AsMut<[u8]> for ClientCookie
source§impl AsRef<[u8]> for ClientCookie
impl AsRef<[u8]> for ClientCookie
source§impl Clone for ClientCookie
impl Clone for ClientCookie
source§fn clone(&self) -> ClientCookie
fn clone(&self) -> ClientCookie
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ClientCookie
impl Debug for ClientCookie
source§impl Default for ClientCookie
impl Default for ClientCookie
source§impl Display for ClientCookie
impl Display for ClientCookie
source§impl From<ClientCookie> for [u8; 8]
impl From<ClientCookie> for [u8; 8]
source§fn from(src: ClientCookie) -> Self
fn from(src: ClientCookie) -> Self
source§impl Hash for ClientCookie
impl Hash for ClientCookie
source§impl Ord for ClientCookie
impl Ord for ClientCookie
source§fn cmp(&self, other: &ClientCookie) -> Ordering
fn cmp(&self, other: &ClientCookie) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
source§impl PartialEq<ClientCookie> for ClientCookie
impl PartialEq<ClientCookie> for ClientCookie
source§fn eq(&self, other: &ClientCookie) -> bool
fn eq(&self, other: &ClientCookie) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<ClientCookie> for ClientCookie
impl PartialOrd<ClientCookie> for ClientCookie
source§fn partial_cmp(&self, other: &ClientCookie) -> Option<Ordering>
fn partial_cmp(&self, other: &ClientCookie) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more