pub struct ProtocolVersion {
pub major: u16,
pub minor: u16,
}Expand description
Protocol version negotiated during the connection handshake.
Fields§
§major: u16Major protocol version component.
minor: u16Minor protocol version component.
Implementations§
Source§impl ProtocolVersion
impl ProtocolVersion
Sourcepub const fn new(major: u16, minor: u16) -> Self
pub const fn new(major: u16, minor: u16) -> Self
Create a protocol version from its major and minor components.
Sourcepub const fn serialize(self) -> [u8; 4]
pub const fn serialize(self) -> [u8; 4]
Serialize this version as big-endian major followed by big-endian minor.
Sourcepub const fn to_wire_bytes(self) -> [u8; 4]
pub const fn to_wire_bytes(self) -> [u8; 4]
Serialize this version for wire transport.
Sourcepub fn deserialize(bytes: &[u8]) -> Result<Self, ProtocolError>
pub fn deserialize(bytes: &[u8]) -> Result<Self, ProtocolError>
Deserialize a protocol version from wire bytes.
§Errors
Returns ProtocolError::CodecError when bytes is not exactly four bytes long.
Sourcepub fn from_wire_bytes(bytes: &[u8]) -> Result<Self, ProtocolError>
pub fn from_wire_bytes(bytes: &[u8]) -> Result<Self, ProtocolError>
Deserialize a protocol version from wire bytes.
§Errors
Returns ProtocolError::CodecError when bytes is not exactly four bytes long.
Trait Implementations§
Source§impl Clone for ProtocolVersion
impl Clone for ProtocolVersion
Source§fn clone(&self) -> ProtocolVersion
fn clone(&self) -> ProtocolVersion
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for ProtocolVersion
Source§impl Debug for ProtocolVersion
impl Debug for ProtocolVersion
impl Eq for ProtocolVersion
Source§impl Ord for ProtocolVersion
impl Ord for ProtocolVersion
Source§fn cmp(&self, other: &ProtocolVersion) -> Ordering
fn cmp(&self, other: &ProtocolVersion) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for ProtocolVersion
impl PartialEq for ProtocolVersion
Source§fn eq(&self, other: &ProtocolVersion) -> bool
fn eq(&self, other: &ProtocolVersion) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl PartialOrd for ProtocolVersion
impl PartialOrd for ProtocolVersion
impl StructuralPartialEq for ProtocolVersion
Auto Trait Implementations§
impl Freeze for ProtocolVersion
impl RefUnwindSafe for ProtocolVersion
impl Send for ProtocolVersion
impl Sync for ProtocolVersion
impl Unpin for ProtocolVersion
impl UnsafeUnpin for ProtocolVersion
impl UnwindSafe for ProtocolVersion
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
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,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.