Skip to main content

SubscribeOutcome

Enum SubscribeOutcome 

Source
#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

Source

pub const CODE_PINNED: i64 = 0

Discriminant for Self::Pinned on the host-function return channel.

Source

pub const CODE_NOT_PINNED: i64 = 1

Discriminant for Self::NotPinned on the host-function return channel.

Source

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.

Source

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

Source§

fn clone(&self) -> SubscribeOutcome

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for SubscribeOutcome

Source§

impl Debug for SubscribeOutcome

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for SubscribeOutcome

Source§

impl PartialEq for SubscribeOutcome

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SubscribeOutcome

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.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

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> Same for T

Source§

type Output = T

Should always be Self
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more