ServerSessionCore

Struct ServerSessionCore 

Source
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

Source

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.

Source

pub const fn state_kind(&self) -> ServerStateKind

Runtime state discriminator.

Source

pub const fn peer(&self) -> SocketAddr

Peer address of this client.

Source

pub const fn protocol_kind(&self) -> ProtocolKind

Runtime protocol discriminator.

Source

pub const fn reflector_module(&self) -> Module

Reflector module for this session.

Source

pub const fn client_callsign(&self) -> Option<Callsign>

Callsign of the linked client, if any.

Source

pub const fn client_module(&self) -> Option<Module>

Local module letter of the linked client, if any.

Source

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.

Source

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.

Source

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.

Source

pub fn next_deadline(&self) -> Option<Instant>

Earliest time the loop needs to re-enter.

Source

pub fn drain_diagnostics(&mut self) -> Vec<Diagnostic>

Drain accumulated parser diagnostics.

Trait Implementations§

Source§

impl Debug for ServerSessionCore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more