pub struct CallsignGenerator { /* private fields */ }Expand description
Callsign generator with collision avoidance.
Tracks used callsigns to ensure uniqueness within a mesh.
Implementations§
Source§impl CallsignGenerator
impl CallsignGenerator
Sourcepub fn new() -> CallsignGenerator
pub fn new() -> CallsignGenerator
Create a new callsign generator.
Sourcepub fn generate(&mut self) -> Result<String, CallsignError>
pub fn generate(&mut self) -> Result<String, CallsignError>
Generate a random unused callsign.
Returns Err(CallsignError::Exhausted) if all 2,600 callsigns are in use.
Sourcepub fn reserve(&mut self, callsign: &str) -> Result<(), CallsignError>
pub fn reserve(&mut self, callsign: &str) -> Result<(), CallsignError>
Reserve a specific callsign for manual assignment.
Returns Ok(()) if the callsign was successfully reserved.
Returns Err if the callsign is invalid or already in use.
Sourcepub fn release(&mut self, callsign: &str) -> bool
pub fn release(&mut self, callsign: &str) -> bool
Release a callsign for reuse.
Returns true if the callsign was found and released.
Sourcepub fn is_available(&self, callsign: &str) -> bool
pub fn is_available(&self, callsign: &str) -> bool
Check if a callsign is available.
Sourcepub fn is_valid_format(callsign: &str) -> bool
pub fn is_valid_format(callsign: &str) -> bool
Check if a callsign has valid format.
Valid format: {NATO_WORD}-{NN} where NN is 00-99.
Sourcepub fn parse(callsign: &str) -> Option<(usize, u8)>
pub fn parse(callsign: &str) -> Option<(usize, u8)>
Parse a callsign into (letter_index, number).
Returns None if the format is invalid.
Sourcepub fn used_count(&self) -> usize
pub fn used_count(&self) -> usize
Get count of used callsigns.
Sourcepub fn available_count(&self) -> usize
pub fn available_count(&self) -> usize
Get count of available callsigns.
Trait Implementations§
Source§impl Clone for CallsignGenerator
impl Clone for CallsignGenerator
Source§fn clone(&self) -> CallsignGenerator
fn clone(&self) -> CallsignGenerator
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CallsignGenerator
impl Debug for CallsignGenerator
Source§impl Default for CallsignGenerator
impl Default for CallsignGenerator
Source§fn default() -> CallsignGenerator
fn default() -> CallsignGenerator
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for CallsignGenerator
impl RefUnwindSafe for CallsignGenerator
impl Send for CallsignGenerator
impl Sync for CallsignGenerator
impl Unpin for CallsignGenerator
impl UnsafeUnpin for CallsignGenerator
impl UnwindSafe for CallsignGenerator
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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