pub struct AgentTable { /* private fields */ }Expand description
A shared, cloneable map of agent target → Runner, with the set of targets the host
expects to serve (spec 3.3 §10 S4). Clones share one table.
§Example
use adk_server::background::AgentTable;
let table = AgentTable::new();
table.expect("finance");
assert!(table.is_expected("finance"));
assert!(table.get("finance").is_none(), "expected, not built yet");
assert!(table.forget("finance"));
assert!(!table.is_expected("finance"));Implementations§
Source§impl AgentTable
impl AgentTable
Sourcepub fn insert(
&self,
target: impl Into<String>,
runner: Arc<Runner>,
) -> Option<Arc<Runner>>
pub fn insert( &self, target: impl Into<String>, runner: Arc<Runner>, ) -> Option<Arc<Runner>>
Hosts runner as target, replacing the runner it had; returns the replaced one.
A claim already running on the replaced runner finishes on it; the next claim of
target runs on runner.
§Example
ⓘ
let table = AgentTable::new();
assert!(table.insert("finance", Arc::new(runner)).is_none());
assert!(table.contains("finance"));Sourcepub fn get(&self, target: &str) -> Option<Arc<Runner>>
pub fn get(&self, target: &str) -> Option<Arc<Runner>>
The runner hosted as target, if any.
§Example
use adk_server::background::AgentTable;
assert!(AgentTable::new().get("finance").is_none());Sourcepub fn contains(&self, target: &str) -> bool
pub fn contains(&self, target: &str) -> bool
Whether a runner is hosted as target.
§Example
use adk_server::background::AgentTable;
assert!(!AgentTable::new().contains("finance"));Sourcepub fn targets(&self) -> Vec<String>
pub fn targets(&self) -> Vec<String>
The hosted targets, sorted.
§Example
use adk_server::background::AgentTable;
assert!(AgentTable::new().targets().is_empty());Sourcepub fn expect(&self, target: impl Into<String>)
pub fn expect(&self, target: impl Into<String>)
Marks target as one the host serves, built or not: a claim of it before it is
built is handed back for a later claim.
§Example
use adk_server::background::AgentTable;
let table = AgentTable::new();
table.expect("finance");
assert_eq!(table.expected(), ["finance"]);Sourcepub fn forget(&self, target: &str) -> bool
pub fn forget(&self, target: &str) -> bool
Stops expecting target; returns whether it was expected. A claim of it that no
runner serves then fails as an unknown target’s does.
§Example
use adk_server::background::AgentTable;
assert!(!AgentTable::new().forget("finance"));Sourcepub fn is_expected(&self, target: &str) -> bool
pub fn is_expected(&self, target: &str) -> bool
Whether the host expects to serve target.
§Example
use adk_server::background::AgentTable;
assert!(!AgentTable::new().is_expected("finance"));Trait Implementations§
Source§impl Clone for AgentTable
impl Clone for AgentTable
Source§impl Debug for AgentTable
impl Debug for AgentTable
Auto Trait Implementations§
impl Forget for AgentTable
impl Freeze for AgentTable
impl Move for AgentTable
impl RefUnwindSafe for AgentTable
impl Send for AgentTable
impl Sync for AgentTable
impl Unpin for AgentTable
impl UnsafeUnpin for AgentTablewhere
*const ArcInner<RwLock<Entries>> is !null: UnsafeUnpin,
PhantomData<ArcInner<RwLock<Entries>>>: UnsafeUnpin,
impl UnwindSafe for AgentTable
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
Mutably borrows from an owned value. Read more
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,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
Converts
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> ⓘ
Converts
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