pub struct ProtocolNegotiator { /* private fields */ }Expand description
Protocol negotiator for version agreement
Implementations§
Source§impl ProtocolNegotiator
impl ProtocolNegotiator
Sourcepub fn prefer(self, version: ProtocolVersion) -> Self
pub fn prefer(self, version: ProtocolVersion) -> Self
Set the preferred protocol version
Sourcepub fn support(self, version: ProtocolVersion) -> Self
pub fn support(self, version: ProtocolVersion) -> Self
Add support for a protocol version
Sourcepub fn unsupport(self, version: ProtocolVersion) -> Self
pub fn unsupport(self, version: ProtocolVersion) -> Self
Remove support for a protocol version
Sourcepub fn is_supported(&self, version: ProtocolVersion) -> bool
pub fn is_supported(&self, version: ProtocolVersion) -> bool
Check if a protocol version is supported
Sourcepub fn supported_versions(&self) -> Vec<ProtocolVersion>
pub fn supported_versions(&self) -> Vec<ProtocolVersion>
Get all supported versions
Sourcepub fn preferred_version(&self) -> Option<ProtocolVersion>
pub fn preferred_version(&self) -> Option<ProtocolVersion>
Get the preferred version
Sourcepub fn negotiate(
&self,
remote_versions: &[ProtocolVersion],
) -> Result<ProtocolVersion, NegotiationError>
pub fn negotiate( &self, remote_versions: &[ProtocolVersion], ) -> Result<ProtocolVersion, NegotiationError>
Negotiate a protocol version with a remote party
Returns the agreed version based on mutual support, preferring our preferred version if mutually supported.
Sourcepub fn validate_version(
&self,
version: ProtocolVersion,
) -> Result<(), NegotiationError>
pub fn validate_version( &self, version: ProtocolVersion, ) -> Result<(), NegotiationError>
Validate that a message uses a supported protocol version
Trait Implementations§
Source§impl Clone for ProtocolNegotiator
impl Clone for ProtocolNegotiator
Source§fn clone(&self) -> ProtocolNegotiator
fn clone(&self) -> ProtocolNegotiator
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 moreSource§impl Debug for ProtocolNegotiator
impl Debug for ProtocolNegotiator
Auto Trait Implementations§
impl Freeze for ProtocolNegotiator
impl RefUnwindSafe for ProtocolNegotiator
impl Send for ProtocolNegotiator
impl Sync for ProtocolNegotiator
impl Unpin for ProtocolNegotiator
impl UnwindSafe for ProtocolNegotiator
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