pub enum Protocol {
Show 21 variants
Begin {
operation: String,
args: Vec<String>,
progress: Option<ProgressAttachment>,
continuation: Box<Protocol>,
},
Await {
operation: String,
continuation: Box<Protocol>,
},
Resolve {
operation: String,
outcome: CommitmentOutcome,
continuation: Box<Protocol>,
},
Invalidate {
operation: String,
continuation: Box<Protocol>,
},
Send {
from: Role,
to: Role,
message: MessageType,
continuation: Box<Protocol>,
annotations: Annotations,
from_annotations: Annotations,
to_annotations: Annotations,
},
Broadcast {
from: Role,
to_all: NonEmptyVec<Role>,
message: MessageType,
continuation: Box<Protocol>,
annotations: Annotations,
from_annotations: Annotations,
},
Choice {
role: Role,
branches: NonEmptyVec<Branch>,
annotations: Annotations,
},
Let {
name: String,
mode: AuthorityBindingMode,
expr: AuthorityExpr,
linear: bool,
continuation: Box<Protocol>,
},
Case {
expr: AuthorityExpr,
branches: NonEmptyVec<CaseBranch>,
},
Timeout {
role: Role,
duration_ms: u64,
body: Box<Protocol>,
on_timeout: Box<Protocol>,
on_cancel: Option<Box<Protocol>>,
},
Loop {
condition: Option<Condition>,
body: Box<Protocol>,
},
Parallel {
protocols: NonEmptyVec<Protocol>,
},
Rec {
label: Ident,
body: Box<Protocol>,
},
Var(Ident),
Publish {
event: String,
arg: Option<String>,
continuation: Box<Protocol>,
},
PublishAuthority {
witness: String,
publication_name: String,
continuation: Box<Protocol>,
},
Materialize {
proof: String,
publication: String,
continuation: Box<Protocol>,
},
Handoff {
operation: String,
target: Role,
receipt: String,
continuation: Box<Protocol>,
},
DependentWork {
name: String,
arg: Option<String>,
required_for: String,
continuation: Box<Protocol>,
},
Extension {
extension: Box<dyn ProtocolExtension>,
continuation: Box<Protocol>,
annotations: Annotations,
},
End,
}Expand description
Protocol specification using choreographic constructs
Variants§
Begin
Begin one explicit semantic operation instance.
Fields
progress: Option<ProgressAttachment>Await
Await one previously begun semantic operation instance.
Resolve
Resolve one previously begun semantic operation instance.
Invalidate
Invalidate one previously begun semantic operation instance.
Send
Message send: A -> B: Message
Fields
message: MessageTypeannotations: AnnotationsStatement-level annotations
from_annotations: AnnotationsFrom role annotations
to_annotations: AnnotationsTo role annotations
Broadcast
Broadcast: A -> *: Message
Fields
to_all: NonEmptyVec<Role>message: MessageTypeannotations: AnnotationsStatement-level annotations
from_annotations: AnnotationsFrom role annotations
Choice
Choice made by a role
Let
Local authority/evidence binding.
Fields
mode: AuthorityBindingModeWhether the binding is authoritative, observational, or plain.
expr: AuthorityExprBound expression.
Case
Local authority/result match.
Timeout
Explicit timeout/cancel surface syntax prior to projection lowering.
Fields
Loop
Loop construct
Parallel
Parallel composition
Fields
protocols: NonEmptyVec<Protocol>Rec
Recursive protocol with label
Var(Ident)
Reference to recursive label
Publish
Canonical semantic publication surface.
PublishAuthority
Canonical publication that lifts an authoritative witness into a named publication.
Materialize
Canonical materialization from one named publication.
Handoff
Explicit semantic owner handoff.
DependentWork
Declared semantically required dependent work.
Extension
Protocol extension point for custom behaviors
Fields
extension: Box<dyn ProtocolExtension>The extension implementation
annotations: AnnotationsStatement-level annotations
End
Protocol termination
Implementations§
Source§impl Protocol
impl Protocol
pub fn mentions_role(&self, role: &Role) -> bool
Sourcepub fn get_annotations(&self) -> &Annotations
pub fn get_annotations(&self) -> &Annotations
Get statement-level annotations for this protocol node
Sourcepub fn get_from_annotations(&self) -> Option<&Annotations>
pub fn get_from_annotations(&self) -> Option<&Annotations>
Get from-role annotations for Send/Broadcast statements
Sourcepub fn get_to_annotations(&self) -> Option<&Annotations>
pub fn get_to_annotations(&self) -> Option<&Annotations>
Get to-role annotations for Send statements
Sourcepub fn get_annotations_mut(&mut self) -> Option<&mut Annotations>
pub fn get_annotations_mut(&mut self) -> Option<&mut Annotations>
Get mutable reference to annotations for modification
Sourcepub fn get_from_annotations_mut(&mut self) -> Option<&mut Annotations>
pub fn get_from_annotations_mut(&mut self) -> Option<&mut Annotations>
Get mutable reference to from-role annotations
Sourcepub fn get_to_annotations_mut(&mut self) -> Option<&mut Annotations>
pub fn get_to_annotations_mut(&mut self) -> Option<&mut Annotations>
Get mutable reference to to-role annotations
Sourcepub fn add_annotation(&mut self, annotation: ProtocolAnnotation) -> bool
pub fn add_annotation(&mut self, annotation: ProtocolAnnotation) -> bool
Add a typed annotation
Sourcepub fn clear_annotations(&mut self)
pub fn clear_annotations(&mut self)
Clear all annotations on this protocol node
Sourcepub fn has_any_annotations(&self) -> bool
pub fn has_any_annotations(&self) -> bool
Check if any annotations are present
Sourcepub fn annotation_count(&self) -> usize
pub fn annotation_count(&self) -> usize
Count total number of annotations (statement + role annotations)
Sourcepub fn merge_annotations_from(&mut self, other: &Protocol)
pub fn merge_annotations_from(&mut self, other: &Protocol)
Merge annotations from another protocol node
Sourcepub fn validate_required_annotations(
&self,
required_keys: &[&str],
) -> Result<(), Vec<String>>
pub fn validate_required_annotations( &self, required_keys: &[&str], ) -> Result<(), Vec<String>>
Validate that required annotations are present
Sourcepub fn collect_nodes_with_annotation<'a>(
&'a self,
key: &str,
nodes: &mut Vec<&'a Protocol>,
)
pub fn collect_nodes_with_annotation<'a>( &'a self, key: &str, nodes: &mut Vec<&'a Protocol>, )
Collect all protocol nodes that have a specific annotation (recursive traversal)
Sourcepub fn collect_nodes_with_annotation_value<'a>(
&'a self,
key: &str,
value: &str,
nodes: &mut Vec<&'a Protocol>,
)
pub fn collect_nodes_with_annotation_value<'a>( &'a self, key: &str, value: &str, nodes: &mut Vec<&'a Protocol>, )
Collect all protocol nodes that have a specific annotation with a specific value
Sourcepub fn deep_annotation_count(&self) -> usize
pub fn deep_annotation_count(&self) -> usize
Count total annotations throughout the protocol tree (recursive)
Sourcepub fn visit_annotated_nodes<F>(&self, f: &mut F)
pub fn visit_annotated_nodes<F>(&self, f: &mut F)
Apply a function to all protocol nodes that have annotations (visitor pattern)
Sourcepub fn visit_annotated_nodes_mut<F>(&mut self, f: &mut F)
pub fn visit_annotated_nodes_mut<F>(&mut self, f: &mut F)
Apply a mutable function to all protocol nodes that have annotations