#[non_exhaustive]pub enum SubscribeOutcome {
Pinned,
NotPinned,
Unrecognized(i64),
}Expand description
What a delegate’s subscribe request actually achieved.
Returned by
DelegateCtx::subscribe_contract_checked.
It exists because Result<(), _> has only two states and the subscribe path
has three: it can register against state the node holds, it can register
against nothing, or it can fail. Reusing Err for the middle case is wrong — delegates
legitimately subscribe before the node has settled, and a usually-transient
condition surfacing as a hard failure would break working delegates today.
This type is not on the wire. It is the decoded form of a non-negative
i64 returned by a host function, so adding a variant costs no bincode
variant tag and cannot shift one.
See freenet-core#5565.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Pinned
The node holds state for this contract, and has recorded the delegate’s interest in it. Notifications have something to fire on.
This is a statement about now, not a durability promise. Under demand-driven hosting no subscription of any kind is an absolute pin, and a delegate subscription is weaker still: it registers notification interest only. On freenet-core as it stands (pre-#4669) it contributes no hosting demand, so it does not affect eviction ordering at all — unlike a client subscription, which is a ranking dimension. freenet-core#5493 implements #4669 and is open now, so treat the “no demand” half as current behaviour rather than a fixed property. A delegate must not read this as “the node will keep this contract for me”; it means the subscription is not vacuous today.
NotPinned
Registered, but the node holds no state for the contract.
This is the case DelegateCtx::subscribe_contract’s doc describes at
length and cannot report. The subscription exists, and there is nothing
for it to fire on: notifications arrive only if some other route
causes this node to hold the contract. The common way to get here is
subscribing at startup, before the node has fetched the contract.
Treat it as “retry later” — and unlike a pin promise, this one does clear: it clears as soon as the node holds the state.
Unrecognized(i64)
The node reported an outcome this build of the stdlib does not know.
A newer node may report an outcome added after this delegate was
compiled. Treating it as Self::Pinned would reintroduce exactly the
silent over-claim this type exists to remove, so it is surfaced.
Implementations§
Source§impl SubscribeOutcome
impl SubscribeOutcome
Sourcepub const CODE_PINNED: i64 = 0
pub const CODE_PINNED: i64 = 0
Discriminant for Self::Pinned on the host-function return channel.
Sourcepub const CODE_NOT_PINNED: i64 = 1
pub const CODE_NOT_PINNED: i64 = 1
Discriminant for Self::NotPinned on the host-function return channel.
Sourcepub fn from_code(code: i64) -> Self
pub fn from_code(code: i64) -> Self
Decode a non-negative host return code.
Negative codes are host errors and never reach here; the caller
separates them first. An unrecognized non-negative code becomes
Self::Unrecognized rather than being folded into a known outcome.
Sourcepub fn is_pinned(self) -> bool
pub fn is_pinned(self) -> bool
Whether the node holds state for the contract and recorded the delegate’s interest — i.e. whether the subscription can fire.
False for Self::NotPinned and for Self::Unrecognized — an
outcome this build cannot interpret is not evidence either way, and
treating it as affirmative is the over-claim this type removes.
Not a durability check. See Self::Pinned: nothing here promises the
node keeps the contract.
Trait Implementations§
Source§impl Clone for SubscribeOutcome
impl Clone for SubscribeOutcome
Source§fn clone(&self) -> SubscribeOutcome
fn clone(&self) -> SubscribeOutcome
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more