pub struct PluginContext {
pub agent_id: String,
pub config: PluginConfig,
/* private fields */
}Expand description
插件执行上下文
Fields§
§agent_id: String智能体 ID
config: PluginConfig插件配置
Implementations§
Source§impl PluginContext
impl PluginContext
pub fn new(agent_id: &str) -> Self
pub fn with_config(self, config: PluginConfig) -> Self
pub fn with_event_sender(self, tx: Sender<PluginEvent>) -> Self
Sourcepub async fn get_state<T: Clone + Send + Sync + 'static>(
&self,
key: &str,
) -> Option<T>
pub async fn get_state<T: Clone + Send + Sync + 'static>( &self, key: &str, ) -> Option<T>
获取共享状态
Sourcepub async fn emit_event(&self, event: PluginEvent) -> Result<()>
pub async fn emit_event(&self, event: PluginEvent) -> Result<()>
发送插件事件
Trait Implementations§
Source§impl Clone for PluginContext
impl Clone for PluginContext
Source§impl Debug for PluginContext
impl Debug for PluginContext
Source§impl Default for PluginContext
impl Default for PluginContext
Source§fn default() -> PluginContext
fn default() -> PluginContext
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PluginContext
impl !RefUnwindSafe for PluginContext
impl Send for PluginContext
impl Sync for PluginContext
impl Unpin for PluginContext
impl UnsafeUnpin for PluginContext
impl !UnwindSafe for PluginContext
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