Callsign

Struct Callsign 

pub struct Callsign(/* private fields */);
Expand description

D-STAR callsign (8 bytes, ASCII, space-padded on the right).

§Invariants

  • Constructed via Self::try_from_str: ASCII, 1..=8 bytes after trimming trailing whitespace, space-padded to exactly 8 bytes.
  • Constructed via Self::from_wire_bytes: any 8 bytes, verbatim. Used on the receive path where real reflectors emit non-printable bytes.

Implementations§

§

impl Callsign

pub fn try_from_str(s: &str) -> Result<Callsign, TypeError>

Try to build a Callsign from a string slice.

  • Must be ASCII
  • Must be 1..=8 bytes (trailing whitespace is trimmed before length check, then space-padded to exactly 8 bytes)
§Errors

Returns TypeError::InvalidCallsign if s is empty, longer than 8 bytes after trimming, or contains non-ASCII characters.

§Example
use dstar_gateway_core::Callsign;
let cs = Callsign::try_from_str("W1AW")?;
assert_eq!(cs.as_bytes(), b"W1AW    "); // space-padded to 8 bytes

pub const fn from_wire_bytes(bytes: [u8; 8]) -> Callsign

Build a Callsign directly from 8 wire bytes, storing them verbatim without any validation.

Used on the receive path. Mirrors ircDDBGateway’s memcpy(m_myCall1, data + 44U, LONG_CALLSIGN_LENGTH) from Common/HeaderData.cpp:622. Real reflectors emit non-printable bytes in callsign fields and a strict ASCII filter would silently drop those headers.

pub const fn as_bytes(&self) -> &[u8; 8]

Return the 8-byte padded representation.

pub fn as_str(&self) -> Cow<'_, str>

Return the trimmed string (no trailing spaces).

Uses lossy UTF-8 conversion via String::from_utf8_lossy so wire bytes stored verbatim via Self::from_wire_bytes that are not valid UTF-8 are rendered with U+FFFD replacement characters rather than panicking.

Trait Implementations§

§

impl Clone for Callsign

§

fn clone(&self) -> Callsign

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Callsign

§

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

Formats the value using the given formatter. Read more
§

impl Display for Callsign

§

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

Formats the value using the given formatter. Read more
§

impl Hash for Callsign

§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl PartialEq for Callsign

§

fn eq(&self, other: &Callsign) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Copy for Callsign

§

impl Eq for Callsign

§

impl StructuralPartialEq for Callsign

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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