pub struct HostHandshake { /* private fields */ }Expand description
Host-side handshake coordinator.
Implementations§
Source§impl HostHandshake
impl HostHandshake
Sourcepub fn new(proposed: Vec<ProtocolId>) -> Self
pub fn new(proposed: Vec<ProtocolId>) -> Self
Creates a new host handshake coordinator with the list of proposed protocols in priority order.
Sourcepub fn proposed(&self) -> &[ProtocolId]
pub fn proposed(&self) -> &[ProtocolId]
Returns the list of proposed protocols.
Sourcepub fn start(&self) -> Result<(FrameType, Vec<u8>), HandshakeError>
pub fn start(&self) -> Result<(FrameType, Vec<u8>), HandshakeError>
Generates the initial negotiation request frame type and serialized payload.
§Errors
Returns HandshakeError::MalformedPayload if the number of proposed protocols
exceeds u8::MAX.
Sourcepub fn handle_response(
&self,
payload: &[u8],
) -> Result<ProtocolId, HandshakeError>
pub fn handle_response( &self, payload: &[u8], ) -> Result<ProtocolId, HandshakeError>
Evaluates a target response payload and returns the mutually agreed protocol.
§Errors
HandshakeError::MalformedPayload: Ifpayloadis shorter than 5 bytes or cannot be parsed.HandshakeError::NoCommonProtocol: If target reported no mutually supported protocol.HandshakeError::ProtocolNotProposed: If target selected a protocol not proposed by this host.HandshakeError::UnsupportedStatus: If target returned an unrecognized status code.
Trait Implementations§
Source§impl Clone for HostHandshake
impl Clone for HostHandshake
Auto Trait Implementations§
impl Freeze for HostHandshake
impl RefUnwindSafe for HostHandshake
impl Send for HostHandshake
impl Sync for HostHandshake
impl Unpin for HostHandshake
impl UnsafeUnpin for HostHandshake
impl UnwindSafe for HostHandshake
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