pub struct SessionSetup {
pub src_coords: TreeCoordinate,
pub dest_coords: TreeCoordinate,
pub flags: SessionFlags,
pub handshake_payload: Vec<u8>,
}Expand description
Session setup to establish cached coordinate state.
Carried inside a SessionDatagram envelope which provides src_addr and dest_addr. The SessionSetup payload contains coordinates, session flags, and the Noise XK handshake message for session establishment.
SessionSetup, SessionAck, and SessionMsg3 are identified by the phase
field in the FSP common prefix (0x1, 0x2, 0x3), not by a message-type byte.
The msg_type field in the encrypted inner header applies only to
established-phase (0x0) messages.
§Wire Format
Encoded with FSP common prefix: [ver_phase:1][flags:1][payload_len:2 LE][body],
where ver_phase = 0x01 (version 0, phase MSG1) and flags = 0 for handshake.
Body (after 4-byte FSP prefix):
| Offset | Field | Size | Description |
|---|---|---|---|
| 0 | flags | 1 byte | Bit 0: REQUEST_ACK, Bit 1: BIDIRECTIONAL |
| 1 | src_coords_count | 2 bytes LE | Number of source coordinate entries |
| 3 | src_coords | 16 × n | Source’s ancestry (NodeAddr, self → root) |
| … | dest_coords_count | 2 bytes LE | Number of dest coordinate entries |
| … | dest_coords | 16 × m | Destination’s ancestry |
| … | handshake_len | 2 bytes LE | Noise payload length |
| … | handshake_payload | variable | Noise XK msg1 (33 bytes — ephemeral key only) |
Fields§
§src_coords: TreeCoordinateSource coordinates (for return path caching).
dest_coords: TreeCoordinateDestination coordinates (for forward routing).
flags: SessionFlagsSession options.
handshake_payload: Vec<u8>Noise IK handshake message 1.
Implementations§
Source§impl SessionSetup
impl SessionSetup
Sourcepub fn new(src_coords: TreeCoordinate, dest_coords: TreeCoordinate) -> Self
pub fn new(src_coords: TreeCoordinate, dest_coords: TreeCoordinate) -> Self
Create a new session setup message.
Sourcepub fn with_flags(self, flags: SessionFlags) -> Self
pub fn with_flags(self, flags: SessionFlags) -> Self
Set session flags.
Sourcepub fn with_handshake(self, payload: Vec<u8>) -> Self
pub fn with_handshake(self, payload: Vec<u8>) -> Self
Set the Noise handshake payload.
Sourcepub fn encode(&self) -> Vec<u8> ⓘ
pub fn encode(&self) -> Vec<u8> ⓘ
Encode as wire format (4-byte FSP prefix + flags + coords + handshake).
The 4-byte prefix: [ver_phase:1][flags:1][payload_len:2 LE]
where ver_phase = 0x01 (version 0, phase MSG1).
Sourcepub fn decode(payload: &[u8]) -> Result<Self, ProtocolError>
pub fn decode(payload: &[u8]) -> Result<Self, ProtocolError>
Decode from wire format (after 4-byte FSP prefix has been consumed).
Trait Implementations§
Source§impl Clone for SessionSetup
impl Clone for SessionSetup
Source§fn clone(&self) -> SessionSetup
fn clone(&self) -> SessionSetup
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SessionSetup
impl RefUnwindSafe for SessionSetup
impl Send for SessionSetup
impl Sync for SessionSetup
impl Unpin for SessionSetup
impl UnsafeUnpin for SessionSetup
impl UnwindSafe for SessionSetup
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more