Skip to main content

ProtocolAnnotation

Enum ProtocolAnnotation 

Source
pub enum ProtocolAnnotation {
    TimedChoice {
        duration: Duration,
    },
    Priority(u32),
    Retry {
        max_attempts: u32,
        delay: Option<Duration>,
    },
    Idempotent,
    Trace {
        label: Option<String>,
    },
    RuntimeTimeout(Duration),
    Heartbeat {
        interval: Duration,
        on_missing_count: u32,
    },
    Parallel,
    Ordered,
    MinResponses(u32),
    Custom {
        key: String,
        value: String,
    },
}
Expand description

A typed annotation on a protocol statement.

Annotations provide metadata that affects code generation or runtime behavior without changing the core session type semantics.

Variants§

§

TimedChoice

Timed choice: race an operation against a timeout.

When applied to a Choice, the choosing role races the operation against the specified duration. If timeout fires first, takes the TimedOut branch; otherwise takes the OnTime branch.

Fields

§duration: Duration

Maximum time to wait before timing out.

§

Priority(u32)

Priority hint for scheduling.

Higher values indicate higher priority. Implementation-specific.

§

Retry

Retry count for transient failures.

Indicates how many times to retry the operation before failing.

Fields

§max_attempts: u32

Maximum retry attempts.

§delay: Option<Duration>

Optional delay between retries.

§

Idempotent

Mark a statement as idempotent (safe to retry).

§

Trace

Trace/debug annotation for logging.

Fields

§label: Option<String>

Optional trace label for identification.

§

RuntimeTimeout(Duration)

Runtime timeout hint (for transport layer, not session type).

Unlike TimedChoice, this doesn’t affect the session type - it’s purely a hint to the transport layer.

§

Heartbeat

Heartbeat pattern: sender sends periodic heartbeats, receiver detects absence.

Desugars to a recursive choice where receiver decides liveness. The runtime uses interval for heartbeat timing and on_missing_count to determine when to declare the sender dead.

Fields

§interval: Duration

Interval between heartbeats.

§on_missing_count: u32

Number of missing heartbeats before declaring dead.

§

Parallel

Execute broadcast/collect operations in parallel.

When applied to a message with a wildcard/range destination, sends or receives are executed concurrently rather than sequentially.

§

Ordered

Preserve strict message ordering.

When applied to a collect operation, messages are returned in the order specified by the role list. This is the default behavior for sequential collect.

§

MinResponses(u32)

Minimum number of responses required for a collect operation.

When applied to a collect with wildcard/range source, the operation succeeds once at least min responses are received. Remaining responses are discarded or handled asynchronously.

§

Custom

Custom annotation for extensions or unknown types.

Falls back to key-value string pairs for extensibility.

Fields

§key: String

The annotation key.

§value: String

The annotation value.

Implementations§

Source§

impl ProtocolAnnotation

Source

pub fn timed_choice(duration: Duration) -> ProtocolAnnotation

Create a timed choice annotation from a duration.

Source

pub fn timed_choice_ms(ms: u64) -> ProtocolAnnotation

Create a timed choice annotation from milliseconds.

Source

pub fn priority(value: u32) -> ProtocolAnnotation

Create a priority annotation.

Source

pub fn retry(max_attempts: u32) -> ProtocolAnnotation

Create a retry annotation with just max attempts.

Source

pub fn retry_with_delay( max_attempts: u32, delay: Duration, ) -> ProtocolAnnotation

Create a retry annotation with delay between attempts.

Source

pub fn trace() -> ProtocolAnnotation

Create a trace annotation without a label.

Source

pub fn trace_labeled(label: impl Into<String>) -> ProtocolAnnotation

Create a trace annotation with a label.

Source

pub fn runtime_timeout(duration: Duration) -> ProtocolAnnotation

Create a runtime timeout annotation.

Source

pub fn heartbeat( interval: Duration, on_missing_count: u32, ) -> ProtocolAnnotation

Create a heartbeat annotation from a duration and missing count.

Source

pub fn heartbeat_ms( interval_ms: u64, on_missing_count: u32, ) -> ProtocolAnnotation

Create a heartbeat annotation from milliseconds and missing count.

Source

pub fn parallel() -> ProtocolAnnotation

Create a parallel annotation.

Source

pub fn ordered() -> ProtocolAnnotation

Create an ordered annotation.

Source

pub fn min_responses(min: u32) -> ProtocolAnnotation

Create a min_responses annotation.

Source

pub fn custom( key: impl Into<String>, value: impl Into<String>, ) -> ProtocolAnnotation

Create a custom annotation.

Source

pub fn is_timed_choice(&self) -> bool

Check if this is a timed choice annotation.

Source

pub fn timed_choice_duration(&self) -> Option<Duration>

Get the timed choice duration, if this is a timed choice.

Source

pub fn is_priority(&self) -> bool

Check if this is a priority annotation.

Source

pub fn priority_value(&self) -> Option<u32>

Get the priority value, if this is a priority annotation.

Source

pub fn is_retry(&self) -> bool

Check if this is a retry annotation.

Source

pub fn retry_config(&self) -> Option<(u32, Option<Duration>)>

Get retry parameters, if this is a retry annotation.

Source

pub fn is_idempotent(&self) -> bool

Check if this is an idempotent annotation.

Source

pub fn is_trace(&self) -> bool

Check if this is a trace annotation.

Source

pub fn is_heartbeat(&self) -> bool

Check if this is a heartbeat annotation.

Source

pub fn heartbeat_params(&self) -> Option<(Duration, u32)>

Get the heartbeat parameters, if this is a heartbeat annotation.

Source

pub fn is_runtime_timeout(&self) -> bool

Check if this is a runtime timeout annotation.

Source

pub fn runtime_timeout_duration(&self) -> Option<Duration>

Get the runtime timeout duration, if this is a runtime timeout annotation.

Source

pub fn is_parallel(&self) -> bool

Check if this is a parallel annotation.

Source

pub fn is_ordered(&self) -> bool

Check if this is an ordered annotation.

Source

pub fn is_min_responses(&self) -> bool

Check if this is a min_responses annotation.

Source

pub fn min_responses_value(&self) -> Option<u32>

Get the min_responses value, if this is a min_responses annotation.

Source

pub fn is_custom_key(&self, expected_key: &str) -> bool

Check if this is a custom annotation with the given key.

Source

pub fn custom_value(&self, expected_key: &str) -> Option<&str>

Get the custom value if this is a custom annotation with the given key.

Trait Implementations§

Source§

impl Clone for ProtocolAnnotation

Source§

fn clone(&self) -> ProtocolAnnotation

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ProtocolAnnotation

Source§

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

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

impl FromIterator<ProtocolAnnotation> for Annotations

Source§

fn from_iter<I>(iter: I) -> Annotations

Creates a value from an iterator. Read more
Source§

impl PartialEq for ProtocolAnnotation

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ProtocolAnnotation

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

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
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<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
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<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> StrictAs for T

Source§

fn strict_as<Dst>(self) -> Dst
where T: StrictCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> StrictCastFrom<Src> for Dst
where Src: StrictCast<Dst>,

Source§

fn strict_cast_from(src: Src) -> Dst

Casts the value.
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> Endpoint for T
where T: Send,

Source§

impl<T> ProgramMessage for T
where T: Clone + Send + Sync + Debug,