pub trait AgentSink: Send + Sync {
// Provided methods
fn step<'a>(
&'a self,
_step: &'a AgentStep,
_credits: u64,
) -> BoxFuture<'a, ()> { ... }
fn cancelled(&self) -> bool { ... }
fn reserve_page<'a>(
&'a self,
_url: &'a str,
) -> BoxFuture<'a, Result<(), ApiError>> { ... }
fn charge_page<'a>(&'a self, _url: &'a str) -> BoxFuture<'a, ()> { ... }
fn release_page<'a>(&'a self, _url: &'a str) -> BoxFuture<'a, ()> { ... }
fn pages_left(&self) -> Option<u64> { ... }
}Expand description
agent 运行的回报和额度,由 API 层的任务管理实现;() 是不回报、不限额的实现。
Provided Methods§
Sourcefn step<'a>(&'a self, _step: &'a AgentStep, _credits: u64) -> BoxFuture<'a, ()>
fn step<'a>(&'a self, _step: &'a AgentStep, _credits: u64) -> BoxFuture<'a, ()>
一次工具调用结束;credits 是到现在为止用掉的额度。
Sourcefn reserve_page<'a>(
&'a self,
_url: &'a str,
) -> BoxFuture<'a, Result<(), ApiError>>
fn reserve_page<'a>( &'a self, _url: &'a str, ) -> BoxFuture<'a, Result<(), ApiError>>
发出一次页面抓取之前调用:原子预留这一页的配额;拒绝时不得发请求。
Sourcefn charge_page<'a>(&'a self, _url: &'a str) -> BoxFuture<'a, ()>
fn charge_page<'a>(&'a self, _url: &'a str) -> BoxFuture<'a, ()>
这一页抓回并会交付:结算预留。
Sourcefn release_page<'a>(&'a self, _url: &'a str) -> BoxFuture<'a, ()>
fn release_page<'a>(&'a self, _url: &'a str) -> BoxFuture<'a, ()>
这一页失败或没有交付:退还预留。
Sourcefn pages_left(&self) -> Option<u64>
fn pages_left(&self) -> Option<u64>
调用方今天还能抓多少页;没有配额时 None。
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".