pub struct ChannelName(/* private fields */);Expand description
A validated channel name.
Names are hierarchical with / separators. Valid characters are
alphanumeric, -, _, ., and /. Names must not be empty,
start or end with /, or contain //.
Backed by Arc<str> so Clone is a refcount bump rather than a
heap allocation. ChannelName is cloned on every nRPC call (the
per-service route cache hands the cached name to the caller
guard), on every publish (the publisher’s ChannelId is cloned
into per-peer dispatch records), and on registry lookups; making
Clone allocation-free removes a class of per-hot-call allocs
without changing any caller code. The validated invariant is
preserved by ::new: there is no public field, no From<String>
or From<&str> impl, and no mutator — once constructed, the
Arc<str> is immutable and aliased copies are safe to share.
Implementations§
Source§impl ChannelName
impl ChannelName
Sourcepub fn new(name: &str) -> Result<ChannelName, ChannelError>
pub fn new(name: &str) -> Result<ChannelName, ChannelError>
Create a new channel name, validating the format.
Sourcepub fn hash(&self) -> u64
pub fn hash(&self) -> u64
Compute the canonical ChannelHash (64-bit) for the name.
This is the substrate-wide key used for ACL, storage, and config decisions. Targeted second-preimage attacks require ~2^64 work even though xxh3 is non-cryptographic.
Sourcepub fn wire_hash(&self) -> u16
pub fn wire_hash(&self) -> u16
Compute the wire u16 channel hash for the Net header fast-path.
The hint stamped on every outgoing packet — fast to compare but only
65,536 buckets, so it has routine collisions at mesh scale.
Control-plane and storage authorization key on
ChannelName::hash (canonical u32), not on this wire hint.
Sourcepub fn is_prefix_of(&self, other: &ChannelName) -> bool
pub fn is_prefix_of(&self, other: &ChannelName) -> bool
Check if this name is a prefix of another (for wildcard subscriptions).
Trait Implementations§
Source§impl Clone for ChannelName
impl Clone for ChannelName
Source§fn clone(&self) -> ChannelName
fn clone(&self) -> ChannelName
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChannelName
impl Debug for ChannelName
Source§impl Display for ChannelName
impl Display for ChannelName
impl Eq for ChannelName
Source§impl Hash for ChannelName
impl Hash for ChannelName
Source§impl PartialEq for ChannelName
impl PartialEq for ChannelName
Source§fn eq(&self, other: &ChannelName) -> bool
fn eq(&self, other: &ChannelName) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ChannelName
Auto Trait Implementations§
impl Freeze for ChannelName
impl RefUnwindSafe for ChannelName
impl Send for ChannelName
impl Sync for ChannelName
impl Unpin for ChannelName
impl UnsafeUnpin for ChannelName
impl UnwindSafe for ChannelName
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
Source§impl<T> CallHasher for T
impl<T> CallHasher for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.