pub struct Label {
pub name: String,
pub sort: PayloadSort,
}Expand description
A message label with its payload sort.
Labels identify message types in communications. Each label has a name and an associated payload type.
§Examples
use telltale_types::{Label, PayloadSort};
// Simple label with unit payload
let hello = Label::new("hello");
assert_eq!(hello.name, "hello");
// Label with typed payload
let data = Label::with_sort("data", PayloadSort::Nat);
assert!(!data.sort.is_simple() || matches!(data.sort, PayloadSort::Nat));Fields§
§name: StringThe label name identifying this message type
sort: PayloadSortThe payload sort for this message
Implementations§
Source§impl Label
impl Label
Sourcepub fn with_sort(name: impl Into<String>, sort: PayloadSort) -> Self
pub fn with_sort(name: impl Into<String>, sort: PayloadSort) -> Self
Create a new label with a specific sort
Sourcepub fn matches(&self, other: &Label) -> bool
pub fn matches(&self, other: &Label) -> bool
Check if this label matches another exactly (name and sort).
Sourcepub fn matches_name(&self, name: &str) -> bool
pub fn matches_name(&self, name: &str) -> bool
Check if this label matches a name
Trait Implementations§
Source§impl Contentable for Label
impl Contentable for Label
Source§fn to_bytes(&self) -> Result<Vec<u8>, ContentableError>
fn to_bytes(&self) -> Result<Vec<u8>, ContentableError>
Serialize to canonical byte representation (JSON format). Read more
Source§fn from_bytes(bytes: &[u8]) -> Result<Self, ContentableError>
fn from_bytes(bytes: &[u8]) -> Result<Self, ContentableError>
Deserialize from JSON bytes. Read more
Source§fn to_template_bytes(&self) -> Result<Vec<u8>, ContentableError>
fn to_template_bytes(&self) -> Result<Vec<u8>, ContentableError>
Serialize to template bytes, allowing open terms with explicit
free-variable interfaces when supported by the implementation. Read more
Source§fn content_id<H: Hasher>(&self) -> Result<ContentId<H>, ContentableError>
fn content_id<H: Hasher>(&self) -> Result<ContentId<H>, ContentableError>
Compute content ID using the specified hasher (from JSON bytes). Read more
Source§fn content_id_default(
&self,
) -> Result<ContentId<DefaultContentHasher>, ContentableError>
fn content_id_default( &self, ) -> Result<ContentId<DefaultContentHasher>, ContentableError>
Compute content ID using the central default content hasher (from JSON bytes). Read more
Source§fn content_id_blake3(&self) -> Result<ContentId<Blake3Hasher>, ContentableError>
fn content_id_blake3(&self) -> Result<ContentId<Blake3Hasher>, ContentableError>
Compute content ID using explicit BLAKE3 (from JSON bytes). Read more
Source§fn template_id<H: Hasher>(&self) -> Result<ContentId<H>, ContentableError>
fn template_id<H: Hasher>(&self) -> Result<ContentId<H>, ContentableError>
Compute a template ID using the specified hasher (from template bytes). Read more
Source§fn template_id_default(
&self,
) -> Result<ContentId<DefaultContentHasher>, ContentableError>
fn template_id_default( &self, ) -> Result<ContentId<DefaultContentHasher>, ContentableError>
Compute a template ID using the central default content hasher. Read more
Source§fn template_id_blake3(
&self,
) -> Result<ContentId<Blake3Hasher>, ContentableError>
fn template_id_blake3( &self, ) -> Result<ContentId<Blake3Hasher>, ContentableError>
Compute a template ID using explicit BLAKE3. Read more
Source§impl<'de> Deserialize<'de> for Label
impl<'de> Deserialize<'de> for Label
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Label
impl StructuralPartialEq for Label
Auto Trait Implementations§
impl Freeze for Label
impl RefUnwindSafe for Label
impl Send for Label
impl Sync for Label
impl Unpin for Label
impl UnsafeUnpin for Label
impl UnwindSafe for Label
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> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
Source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Performs the conversion.
Source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
Source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Performs the conversion.
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> StrictAs for T
impl<T> StrictAs for T
Source§fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
fn strict_as<Dst>(self) -> Dstwhere
T: StrictCast<Dst>,
Casts the value.
Source§impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
impl<Src, Dst> StrictCastFrom<Src> for Dstwhere
Src: StrictCast<Dst>,
Source§fn strict_cast_from(src: Src) -> Dst
fn strict_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
Source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
Source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.