Trait PluginStreamMessage

Source
pub trait PluginStreamMessage {
    // Required methods
    fn send_message_stream_start(
        &self,
        plugin_ctx: &PluginInstanceContext,
    ) -> Result<String, StreamError>;
    fn send_message_stream(
        &self,
        stream_id: &str,
        chunk: &str,
        is_final: bool,
        plugin_ctx: &PluginInstanceContext,
    ) -> Result<(), StreamError>;
    fn send_message_stream_end(
        &self,
        stream_id: &str,
        success: bool,
        error_msg: Option<&str>,
        plugin_ctx: &PluginInstanceContext,
    ) -> Result<(), StreamError>;
    fn send_message_stream_pause(
        &self,
        stream_id: &str,
        plugin_ctx: &PluginInstanceContext,
    ) -> Result<(), StreamError>;
    fn send_message_stream_resume(
        &self,
        stream_id: &str,
        plugin_ctx: &PluginInstanceContext,
    ) -> Result<(), StreamError>;
    fn send_message_stream_cancel(
        &self,
        stream_id: &str,
        plugin_ctx: &PluginInstanceContext,
    ) -> Result<(), StreamError>;
    fn get_stream_status(&self, stream_id: &str) -> Option<StreamStatus>;
    fn list_active_streams(
        &self,
        plugin_ctx: &PluginInstanceContext,
    ) -> Vec<String>;
    fn send_message_stream_batch(
        &self,
        stream_id: &str,
        chunks: &[&str],
        plugin_ctx: &PluginInstanceContext,
    ) -> Result<(), StreamError>;
}
Expand description

插件流式消息发送器 重新设计以支持上下文传递模式

Required Methods§

Source

fn send_message_stream_start( &self, plugin_ctx: &PluginInstanceContext, ) -> Result<String, StreamError>

开始流式传输,返回流ID

Source

fn send_message_stream( &self, stream_id: &str, chunk: &str, is_final: bool, plugin_ctx: &PluginInstanceContext, ) -> Result<(), StreamError>

发送流式数据块

Source

fn send_message_stream_end( &self, stream_id: &str, success: bool, error_msg: Option<&str>, plugin_ctx: &PluginInstanceContext, ) -> Result<(), StreamError>

结束流式传输

Source

fn send_message_stream_pause( &self, stream_id: &str, plugin_ctx: &PluginInstanceContext, ) -> Result<(), StreamError>

暂停流式传输

Source

fn send_message_stream_resume( &self, stream_id: &str, plugin_ctx: &PluginInstanceContext, ) -> Result<(), StreamError>

恢复流式传输

Source

fn send_message_stream_cancel( &self, stream_id: &str, plugin_ctx: &PluginInstanceContext, ) -> Result<(), StreamError>

取消流式传输

Source

fn get_stream_status(&self, stream_id: &str) -> Option<StreamStatus>

获取流状态

Source

fn list_active_streams(&self, plugin_ctx: &PluginInstanceContext) -> Vec<String>

列出活跃的流

Source

fn send_message_stream_batch( &self, stream_id: &str, chunks: &[&str], plugin_ctx: &PluginInstanceContext, ) -> Result<(), StreamError>

批量发送流式数据

Implementors§