Skip to main content

negotiate_version

Function negotiate_version 

Source
pub fn negotiate_version(
    client_versions: &[VarInt],
    server_version: VarInt,
) -> Result<VarInt, SetupError>
Expand description

Negotiate a version from the client’s offered list and the server’s selected version.

A client may offer other drafts’ versions beside this one, but this module encodes exactly one draft: a session that settled on another version would have every frame after the handshake written in the wrong format, and the first symptom would be the peer closing it. So a selected version that is not this draft’s is refused here rather than carried.

§Errors

SetupError::WrongDraftVersion if the server selected a version this module does not implement, and SetupError::NoCommonVersion if it selected one the client did not offer.