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§
Sourcefn send_message_stream_start(
&self,
plugin_ctx: &PluginInstanceContext,
) -> Result<String, StreamError>
fn send_message_stream_start( &self, plugin_ctx: &PluginInstanceContext, ) -> Result<String, StreamError>
开始流式传输,返回流ID
Sourcefn send_message_stream(
&self,
stream_id: &str,
chunk: &str,
is_final: bool,
plugin_ctx: &PluginInstanceContext,
) -> Result<(), StreamError>
fn send_message_stream( &self, stream_id: &str, chunk: &str, is_final: bool, plugin_ctx: &PluginInstanceContext, ) -> Result<(), StreamError>
发送流式数据块
Sourcefn send_message_stream_end(
&self,
stream_id: &str,
success: bool,
error_msg: Option<&str>,
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>
结束流式传输
Sourcefn send_message_stream_pause(
&self,
stream_id: &str,
plugin_ctx: &PluginInstanceContext,
) -> Result<(), StreamError>
fn send_message_stream_pause( &self, stream_id: &str, plugin_ctx: &PluginInstanceContext, ) -> Result<(), StreamError>
暂停流式传输
Sourcefn send_message_stream_resume(
&self,
stream_id: &str,
plugin_ctx: &PluginInstanceContext,
) -> Result<(), StreamError>
fn send_message_stream_resume( &self, stream_id: &str, plugin_ctx: &PluginInstanceContext, ) -> Result<(), StreamError>
恢复流式传输
Sourcefn send_message_stream_cancel(
&self,
stream_id: &str,
plugin_ctx: &PluginInstanceContext,
) -> Result<(), StreamError>
fn send_message_stream_cancel( &self, stream_id: &str, plugin_ctx: &PluginInstanceContext, ) -> Result<(), StreamError>
取消流式传输
Sourcefn get_stream_status(&self, stream_id: &str) -> Option<StreamStatus>
fn get_stream_status(&self, stream_id: &str) -> Option<StreamStatus>
获取流状态
Sourcefn list_active_streams(&self, plugin_ctx: &PluginInstanceContext) -> Vec<String>
fn list_active_streams(&self, plugin_ctx: &PluginInstanceContext) -> Vec<String>
列出活跃的流
Sourcefn send_message_stream_batch(
&self,
stream_id: &str,
chunks: &[&str],
plugin_ctx: &PluginInstanceContext,
) -> Result<(), StreamError>
fn send_message_stream_batch( &self, stream_id: &str, chunks: &[&str], plugin_ctx: &PluginInstanceContext, ) -> Result<(), StreamError>
批量发送流式数据