pub struct ServerSessionCore { /* private fields */ }Expand description
Protocol-erased server-side session machine.
Each instance tracks one client. The dstar-gateway-server shell
spawns a ServerSessionCore per inbound peer and routes datagrams
through Self::handle_input. The typestate wrapper
super::ServerSession sits on top and adds compile-time state
discrimination.
Implementations§
Source§impl ServerSessionCore
impl ServerSessionCore
Sourcepub fn new(
kind: ProtocolKind,
peer: SocketAddr,
reflector_module: Module,
) -> Self
pub fn new( kind: ProtocolKind, peer: SocketAddr, reflector_module: Module, ) -> Self
Create a new server session for a client with the given protocol, peer, and reflector module.
reflector_module is the module this reflector endpoint is
bound to — used as the default for DPlus ClientLinked
events and overwritten on LINK for DExtra/DCS which carry
their own module in the wire packet.
Sourcepub const fn state_kind(&self) -> ServerStateKind
pub const fn state_kind(&self) -> ServerStateKind
Runtime state discriminator.
Sourcepub const fn peer(&self) -> SocketAddr
pub const fn peer(&self) -> SocketAddr
Peer address of this client.
Sourcepub const fn protocol_kind(&self) -> ProtocolKind
pub const fn protocol_kind(&self) -> ProtocolKind
Runtime protocol discriminator.
Sourcepub const fn reflector_module(&self) -> Module
pub const fn reflector_module(&self) -> Module
Reflector module for this session.
Sourcepub const fn client_callsign(&self) -> Option<Callsign>
pub const fn client_callsign(&self) -> Option<Callsign>
Callsign of the linked client, if any.
Sourcepub const fn client_module(&self) -> Option<Module>
pub const fn client_module(&self) -> Option<Module>
Local module letter of the linked client, if any.
Sourcepub fn handle_input(&mut self, now: Instant, bytes: &[u8]) -> Result<(), Error>
pub fn handle_input(&mut self, now: Instant, bytes: &[u8]) -> Result<(), Error>
Feed an inbound datagram into the server session.
Parses the bytes, updates state, pushes events and outbound
packets as needed. Protocol-erased dispatch: matches on
Self::protocol_kind and calls the appropriate decoder.
§Errors
Returns Error::Protocol wrapping the codec error if the
datagram cannot be parsed.
Sourcepub fn pop_transmit(&mut self, now: Instant) -> Option<Transmit<'_>>
pub fn pop_transmit(&mut self, now: Instant) -> Option<Transmit<'_>>
Pop the next outbound packet (from the outbox).
Holds the popped packet in current_tx so the returned
Transmit can borrow from it across calls.
Sourcepub fn pop_event<P: Protocol>(&mut self) -> Option<ServerEvent<P>>
pub fn pop_event<P: Protocol>(&mut self) -> Option<ServerEvent<P>>
Drain the next event, typed with the correct protocol marker.
The P type parameter re-attaches the protocol phantom at
drain time — the event queue itself is protocol-erased.
Sourcepub fn next_deadline(&self) -> Option<Instant>
pub fn next_deadline(&self) -> Option<Instant>
Earliest time the loop needs to re-enter.
Sourcepub fn drain_diagnostics(&mut self) -> Vec<Diagnostic>
pub fn drain_diagnostics(&mut self) -> Vec<Diagnostic>
Drain accumulated parser diagnostics.