pub enum GlobalType {
End,
Message {
from: Role,
to: Role,
payload: Payload,
cont: Box<GlobalType>,
},
Choice {
from: Role,
to: Role,
arms: BTreeMap<String, GlobalType>,
},
Rec(String, Box<GlobalType>),
Var(String),
}Expand description
A global session type — the protocol viewed from above. Each constructor names every participant explicitly so projection has no ambiguity.
Serialisable so a global type can travel between deployment stages (declaration in source → IR → an enterprise registry that drives the §41.f WS surface). Hashable so a deployment can fingerprint the declared protocol before issuing snapshots that bind to it.
Variants§
End
end — the protocol terminates.
Message
p → q : T . G — role from sends a value of type payload to
role to, then the protocol continues as cont. from ≠ to is
enforced by the projection gate (a self-message has no operational
meaning at the global layer).
Choice
p → q : { ℓᵢ : Gᵢ } — role from selects label ℓᵢ, sends it
to to, the protocol continues as Gᵢ. The label set is canonical
(BTreeMap); arms must be non-empty.
Rec(String, Box<GlobalType>)
μX. G — recursive protocol. Bind var in body.
Var(String)
X — recursion variable. Free vars on the gate’s input are an
error (ProjectionError::UnboundVariable).
Implementations§
Source§impl GlobalType
impl GlobalType
Sourcepub fn message(
from: impl Into<String>,
to: impl Into<String>,
payload: impl Into<String>,
cont: GlobalType,
) -> GlobalType
pub fn message( from: impl Into<String>, to: impl Into<String>, payload: impl Into<String>, cont: GlobalType, ) -> GlobalType
from → to : payload . cont.
Sourcepub fn choice(
from: impl Into<String>,
to: impl Into<String>,
arms: impl IntoIterator<Item = (String, GlobalType)>,
) -> GlobalType
pub fn choice( from: impl Into<String>, to: impl Into<String>, arms: impl IntoIterator<Item = (String, GlobalType)>, ) -> GlobalType
from → to : { ℓ : G, … }.
Sourcepub fn rec(var: impl Into<String>, body: GlobalType) -> GlobalType
pub fn rec(var: impl Into<String>, body: GlobalType) -> GlobalType
μX. G.
Sourcepub fn var(name: impl Into<String>) -> GlobalType
pub fn var(name: impl Into<String>) -> GlobalType
X.
Sourcepub fn roles(&self) -> BTreeSet<Role>
pub fn roles(&self) -> BTreeSet<Role>
Every participant named anywhere in self. Used by
Self::project_all to drive the per-role projection loop.
Sourcepub fn project(&self, r: &Role) -> Result<SessionType, ProjectionError>
pub fn project(&self, r: &Role) -> Result<SessionType, ProjectionError>
Project self to the local session type role r is expected to
run. Returns the binary SessionType the §41.a algebra +
§41.d runtime consume.
Total over closed, contractive global types; rejects only if the gate fires:
ProjectionError::SelfMessage—from == tosomewhere;ProjectionError::MergeFailed— a non-participating role couldn’t observe the choice (arms diverge);ProjectionError::EmptyChoice—Choice { arms: {} };ProjectionError::UnboundVariable—Var(x)without an enclosingRec(x, _)on the path.
Sourcepub fn project_all(
&self,
) -> Result<BTreeMap<Role, SessionType>, ProjectionError>
pub fn project_all( &self, ) -> Result<BTreeMap<Role, SessionType>, ProjectionError>
Project for every role this global type mentions. A Result::Ok
is the safe-realizability certificate: every endpoint has a
well-defined local protocol, and any compliant per-role runtime
composes into a faithful realisation of self.
Sourcepub fn is_safely_realizable(&self) -> bool
pub fn is_safely_realizable(&self) -> bool
Is self safely realisable? Convenience wrapper around
Self::project_all for callers that only care about the gate
verdict (the type-checker’s safety predicate).
Trait Implementations§
Source§impl Clone for GlobalType
impl Clone for GlobalType
Source§fn clone(&self) -> GlobalType
fn clone(&self) -> GlobalType
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GlobalType
impl Debug for GlobalType
Source§impl<'de> Deserialize<'de> for GlobalType
impl<'de> Deserialize<'de> for GlobalType
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<GlobalType, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<GlobalType, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for GlobalType
Source§impl Hash for GlobalType
impl Hash for GlobalType
Source§impl PartialEq for GlobalType
impl PartialEq for GlobalType
Source§fn eq(&self, other: &GlobalType) -> bool
fn eq(&self, other: &GlobalType) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for GlobalType
impl Serialize for GlobalType
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for GlobalType
Auto Trait Implementations§
impl Freeze for GlobalType
impl RefUnwindSafe for GlobalType
impl Send for GlobalType
impl Sync for GlobalType
impl Unpin for GlobalType
impl UnsafeUnpin for GlobalType
impl UnwindSafe for GlobalType
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more