SessionBuilder

Struct SessionBuilder 

Source
pub struct SessionBuilder<P: Protocol, Cs, Lm, Rm, Pe> { /* private fields */ }
Expand description

Typestate builder for Session<P, Configured>.

Parameters:

All four Missing/Provided type parameters start as Missing and must be flipped to Provided before Self::build becomes callable. The phantoms add zero runtime cost.

Implementations§

Source§

impl<P: Protocol, Cs, Lm, Rm, Pe> SessionBuilder<P, Cs, Lm, Rm, Pe>

Source

pub const fn callsign( self, callsign: Callsign, ) -> SessionBuilder<P, Provided, Lm, Rm, Pe>

Set the station callsign.

Source

pub const fn local_module( self, module: Module, ) -> SessionBuilder<P, Cs, Provided, Rm, Pe>

Set the local module letter (the module on the client side).

Source

pub const fn reflector_module( self, module: Module, ) -> SessionBuilder<P, Cs, Lm, Provided, Pe>

Set the reflector module letter (the module we want to link to).

Source

pub const fn peer( self, peer: SocketAddr, ) -> SessionBuilder<P, Cs, Lm, Rm, Provided>

Set the reflector peer address.

Source

pub const fn reflector_callsign(self, reflector_callsign: Callsign) -> Self

Set the target reflector’s own callsign.

Required for DCS sessions targeting any reflector other than DCS001. The DCS wire format embeds the reflector callsign in every LINK / UNLINK / POLL packet, and a real DCS030 reflector will silently drop traffic whose embedded reflector callsign reads DCS001 . For DPlus and DExtra this is metadata only — the protocols do not carry the reflector callsign on the wire, so the setter is harmless when unused.

Unlike the four required fields, this setter does not flip a typestate marker — sessions that do not need a reflector callsign keep building with four setters, and DCS sessions that forget it get a runtime warning at construction time plus a DCS001 fallback. Upgrading this to a compile-time requirement for Session<Dcs, _> specifically is a future design refinement.

Source§

impl<P: Protocol> SessionBuilder<P, Provided, Provided, Provided, Provided>

Source

pub fn build(self) -> Session<P, Configured>

Build the Session<P, Configured>.

Only callable when all four required fields have been set — any Missing marker turns this into a compile error.

The Provided type parameters are the typestate proof that every field was set; the Option unwrapping below is therefore infallible at the type level, and we use unreachable! in the impossible branches rather than Option::expect (which is lint-denied in lib code).

Trait Implementations§

Source§

impl<P: Debug + Protocol, Cs: Debug, Lm: Debug, Rm: Debug, Pe: Debug> Debug for SessionBuilder<P, Cs, Lm, Rm, Pe>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<P, Cs, Lm, Rm, Pe> Freeze for SessionBuilder<P, Cs, Lm, Rm, Pe>

§

impl<P, Cs, Lm, Rm, Pe> RefUnwindSafe for SessionBuilder<P, Cs, Lm, Rm, Pe>

§

impl<P, Cs, Lm, Rm, Pe> Send for SessionBuilder<P, Cs, Lm, Rm, Pe>
where Cs: Send, Lm: Send, Rm: Send, Pe: Send,

§

impl<P, Cs, Lm, Rm, Pe> Sync for SessionBuilder<P, Cs, Lm, Rm, Pe>
where Cs: Sync, Lm: Sync, Rm: Sync, Pe: Sync,

§

impl<P, Cs, Lm, Rm, Pe> Unpin for SessionBuilder<P, Cs, Lm, Rm, Pe>
where P: Unpin, Cs: Unpin, Lm: Unpin, Rm: Unpin, Pe: Unpin,

§

impl<P, Cs, Lm, Rm, Pe> UnwindSafe for SessionBuilder<P, Cs, Lm, Rm, Pe>
where P: UnwindSafe, Cs: UnwindSafe, Lm: UnwindSafe, Rm: UnwindSafe, Pe: UnwindSafe,

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