pub struct OperatorRef(/* private fields */);Expand description
The logical Operator role handle (main-ai, phase_a_op, …),
re-exported here so it sits alongside SessionId — the other half of
the operator-login identity pair — despite being defined one layer down.
It has to be defined in mlua-swarm-schema rather than in this module:
crate::BindRequest carries one as binding_target, and that struct
lives in the schema crate, which does not (and must not) depend on this
one. Not to be confused with Role below, which is the closed
authorization enum (Operator / Worker / Observer / Senior).
Logical Operator role handle — the one type behind the three names the
same concept used to carry: a Blueprint’s AgentDef.spec.operator_ref,
a BindRequest::binding_target, and the roles a
POST /v1/operators login mints.
§Why a newtype and not String
Those three sites name one thing: “which Operator is meant”, written by
the Blueprint author and claimed at login. Spelling it String
everywhere let it be swapped at a call site with the several other
strings that travel alongside it — an agent name, a session id, a
launch variant — none of which the compiler could tell apart.
Deliberately not built from the id_newtype! macro: that shape
mints <PREFIX>-<hex> values and validates the prefix, which fits a
server-minted id like BindingDigest’s siblings. An OperatorRef is
authored, not minted (main-ai, phase_a_op), so it carries no prefix
and no generated form.
§The only rule is “not empty”
No naming convention is imposed — every name an existing Blueprint
already uses stays valid. An empty ref is rejected because it can only
be a mistake: nothing can hold the role "", so it names no Operator
and would fail later, further from the author who wrote it.
The wire form is unchanged: a plain string in both directions
(#[serde(try_from = "String")] over a newtype, so serialization is the
inner string verbatim and deserialization runs the emptiness check at
the boundary).
Implementations§
Source§impl OperatorRef
impl OperatorRef
Sourcepub fn new(name: impl Into<String>) -> Result<OperatorRef, EmptyOperatorRef>
pub fn new(name: impl Into<String>) -> Result<OperatorRef, EmptyOperatorRef>
Build a ref from an authored name, rejecting only the empty string.
Sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Consume the ref and return the inner string.
Trait Implementations§
Source§impl AsRef<str> for OperatorRef
impl AsRef<str> for OperatorRef
Source§impl Borrow<str> for OperatorRef
Lets a HashMap<OperatorRef, _> be probed with a plain &str, so a
lookup does not have to allocate (or fallibly construct) a ref first.
impl Borrow<str> for OperatorRef
Lets a HashMap<OperatorRef, _> be probed with a plain &str, so a
lookup does not have to allocate (or fallibly construct) a ref first.
Sound because the derived Hash / Eq on this newtype are exactly the
inner String’s, which are in turn str’s — the Borrow contract’s
requirement that borrowed and owned forms hash and compare identically.
Source§impl Clone for OperatorRef
impl Clone for OperatorRef
Source§fn clone(&self) -> OperatorRef
fn clone(&self) -> OperatorRef
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 OperatorRef
impl Debug for OperatorRef
Source§impl<'de> Deserialize<'de> for OperatorRef
impl<'de> Deserialize<'de> for OperatorRef
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<OperatorRef, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<OperatorRef, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for OperatorRef
impl Display for OperatorRef
impl Eq for OperatorRef
Source§impl FromStr for OperatorRef
impl FromStr for OperatorRef
Source§type Err = EmptyOperatorRef
type Err = EmptyOperatorRef
Source§fn from_str(name: &str) -> Result<OperatorRef, EmptyOperatorRef>
fn from_str(name: &str) -> Result<OperatorRef, EmptyOperatorRef>
s to return a value of this type. Read moreSource§impl Hash for OperatorRef
impl Hash for OperatorRef
Source§impl Ord for OperatorRef
impl Ord for OperatorRef
Source§fn cmp(&self, other: &OperatorRef) -> Ordering
fn cmp(&self, other: &OperatorRef) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for OperatorRef
impl PartialEq for OperatorRef
Source§impl PartialOrd for OperatorRef
impl PartialOrd for OperatorRef
Source§impl Serialize for OperatorRef
impl Serialize for OperatorRef
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 OperatorRef
Source§impl TryFrom<String> for OperatorRef
impl TryFrom<String> for OperatorRef
Source§type Error = EmptyOperatorRef
type Error = EmptyOperatorRef
Source§fn try_from(name: String) -> Result<OperatorRef, EmptyOperatorRef>
fn try_from(name: String) -> Result<OperatorRef, EmptyOperatorRef>
Auto Trait Implementations§
impl Freeze for OperatorRef
impl RefUnwindSafe for OperatorRef
impl Send for OperatorRef
impl Sync for OperatorRef
impl Unpin for OperatorRef
impl UnsafeUnpin for OperatorRef
impl UnwindSafe for OperatorRef
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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