pub struct MemSource { /* private fields */ }Expand description
A plugin package held entirely in memory.
Keys are /-separated paths relative to the plugin root; directories
exist implicitly wherever a key has a parent. There are no symlinks, so
every path is truthfully confined.
use agent_plugins::MemSource;
let plugin = MemSource::new()
.file("plugin.json", br#"{
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
"name": "in-memory"
}"#)
.load()
.unwrap();
assert_eq!(plugin.manifest.name.as_str(), "in-memory");Implementations§
Trait Implementations§
Source§impl Source for MemSource
impl Source for MemSource
Source§type Error = !
type Error = !
The source’s own failure type. Failures are folded into the loading
conversation as
Answer::Unavailable, where the spec’s failure
boundaries decide how far the damage spreads.Source§fn kind(&mut self, path: &PackagePath) -> Result<Option<FileKind>, Infallible>
fn kind(&mut self, path: &PackagePath) -> Result<Option<FileKind>, Infallible>
What kind of entry does
path resolve to? None if absent.Source§fn confined(&mut self, _path: &PackagePath) -> Result<bool, Infallible>
fn confined(&mut self, _path: &PackagePath) -> Result<bool, Infallible>
Does
path, fully resolved, stay within the plugin root? Sources
that cannot contain links may simply return Ok(true).Source§fn read(&mut self, path: &PackagePath) -> Result<Vec<u8>, Infallible>
fn read(&mut self, path: &PackagePath) -> Result<Vec<u8>, Infallible>
Read the file at
path.Source§fn list(&mut self, path: &PackagePath) -> Result<Vec<DirEntry>, Infallible>
fn list(&mut self, path: &PackagePath) -> Result<Vec<DirEntry>, Infallible>
List the immediate entries of the directory at
path.Auto Trait Implementations§
impl Freeze for MemSource
impl RefUnwindSafe for MemSource
impl Send for MemSource
impl Sync for MemSource
impl Unpin for MemSource
impl UnsafeUnpin for MemSource
impl UnwindSafe for MemSource
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