pub struct StreamAnchorHandle(/* private fields */);Expand description
Compact wire handle encoding a WorkerId (upper 64 bits) and a local anchor ID
(lower 64 bits) into a single u128.
Serializes via rmp-serde as a two-field struct {hi: u64, lo: u64} — not as raw
binary bytes — to guarantee correct round-tripping across msgpack boundaries.
The high bit of the local_id slot ([MPSC_STREAM_BIT]) is reserved as a
kind discriminator: 0 → SPSC anchor, 1 → MPSC anchor. Use
StreamAnchorHandle::pack for SPSC handles and
StreamAnchorHandle::pack_mpsc for MPSC handles;
StreamAnchorHandle::is_spsc_stream / StreamAnchorHandle::is_mpsc_stream
let the attach entry points fail fast on the wrong kind without wasting an
AM round-trip.
local_id of 0 is reserved; crate::streaming::anchor::AnchorManager assigns IDs starting at 1.
Implementations§
Source§impl StreamAnchorHandle
impl StreamAnchorHandle
Sourcepub fn pack(worker_id: WorkerId, local_id: u64) -> Self
pub fn pack(worker_id: WorkerId, local_id: u64) -> Self
Encode a WorkerId and local SPSC anchor ID into a StreamAnchorHandle.
local_id of 0 is reserved. Callers should start local IDs at 1.
§Panics (debug only)
Debug-asserts that the high bit of local_id is clear.
[MPSC_STREAM_BIT] is reserved for MPSC handles; use
pack_mpsc if you need an MPSC anchor handle.
Sourcepub fn pack_mpsc(worker_id: WorkerId, local_id: u64) -> Self
pub fn pack_mpsc(worker_id: WorkerId, local_id: u64) -> Self
Encode a WorkerId and local MPSC anchor ID into a
StreamAnchorHandle, setting the [MPSC_STREAM_BIT] discriminator.
local_id is the raw 63-bit counter value; this function ORs in the
kind bit. See pack for SPSC.
§Panics (debug only)
Debug-asserts that the high bit of local_id is clear so callers do
not double-apply the mask.
Sourcepub fn unpack(&self) -> (WorkerId, u64)
pub fn unpack(&self) -> (WorkerId, u64)
Decode the WorkerId and local anchor ID from this handle.
The returned local_id retains the [MPSC_STREAM_BIT] if set — it is
the value used as the key in the respective anchor registry
(SPSC/MPSC registries live in disjoint key ranges thanks to the bit).
Sourcepub fn kind(&self) -> AnchorKind
pub fn kind(&self) -> AnchorKind
Return the AnchorKind encoded in the handle.
Sourcepub fn is_mpsc_stream(&self) -> bool
pub fn is_mpsc_stream(&self) -> bool
true iff this handle refers to an MPSC anchor
(the [MPSC_STREAM_BIT] is set in the local_id).
Sourcepub fn is_spsc_stream(&self) -> bool
pub fn is_spsc_stream(&self) -> bool
true iff this handle refers to an SPSC anchor.
Trait Implementations§
Source§impl Clone for StreamAnchorHandle
impl Clone for StreamAnchorHandle
Source§fn clone(&self) -> StreamAnchorHandle
fn clone(&self) -> StreamAnchorHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for StreamAnchorHandle
Source§impl Debug for StreamAnchorHandle
impl Debug for StreamAnchorHandle
Source§impl<'de> Deserialize<'de> for StreamAnchorHandle
impl<'de> Deserialize<'de> for StreamAnchorHandle
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Source§impl Display for StreamAnchorHandle
impl Display for StreamAnchorHandle
impl Eq for StreamAnchorHandle
Source§impl Hash for StreamAnchorHandle
impl Hash for StreamAnchorHandle
Source§impl PartialEq for StreamAnchorHandle
impl PartialEq for StreamAnchorHandle
Source§impl Serialize for StreamAnchorHandle
impl Serialize for StreamAnchorHandle
impl StructuralPartialEq for StreamAnchorHandle
Auto Trait Implementations§
impl Freeze for StreamAnchorHandle
impl RefUnwindSafe for StreamAnchorHandle
impl Send for StreamAnchorHandle
impl Sync for StreamAnchorHandle
impl Unpin for StreamAnchorHandle
impl UnsafeUnpin for StreamAnchorHandle
impl UnwindSafe for StreamAnchorHandle
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request