pub struct FileTool { /* private fields */ }Expand description
文件读写工具(限制在 base_path 沙箱内,扩展名白名单,大小限制)
Implementations§
Source§impl FileTool
impl FileTool
pub fn new(base_path: PathBuf) -> Self
pub fn with_allowed_extensions(self, exts: Vec<String>) -> Self
pub fn with_max_size(self, size: usize) -> Self
pub async fn read(&self, path: &str) -> Result<String, ToolError>
pub async fn write(&self, path: &str, content: &str) -> Result<(), ToolError>
pub async fn list(&self, dir: &str) -> Result<Vec<String>, ToolError>
Trait Implementations§
Source§impl BaseTool for FileTool
impl BaseTool for FileTool
Source§fn description(&self) -> &str
fn description(&self) -> &str
Returns the tool description. Read more
Source§fn run<'life0, 'async_trait>(
&'life0 self,
input: String,
) -> Pin<Box<dyn Future<Output = Result<String, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn run<'life0, 'async_trait>(
&'life0 self,
input: String,
) -> Pin<Box<dyn Future<Output = Result<String, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the tool (string version). Read more
Source§fn return_direct(&self) -> bool
fn return_direct(&self) -> bool
Whether to return result directly to user. Read more
Auto Trait Implementations§
impl Freeze for FileTool
impl RefUnwindSafe for FileTool
impl Send for FileTool
impl Sync for FileTool
impl Unpin for FileTool
impl UnsafeUnpin for FileTool
impl UnwindSafe for FileTool
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