pub struct Storage { /* private fields */ }Expand description
Local filesystem storage for cached llms.txt documentation
Implementations§
Source§impl Storage
impl Storage
Sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Creates a new storage instance with the default root directory.
§Errors
Returns an error if the data or config directories cannot be resolved or created.
Sourcepub fn with_root(root_dir: PathBuf) -> Result<Self>
pub fn with_root(root_dir: PathBuf) -> Result<Self>
Creates a new storage instance with a custom root directory.
§Errors
Returns an error if the data or config directories cannot be created.
Sourcepub fn with_paths(root_dir: PathBuf, config_dir: PathBuf) -> Result<Self>
pub fn with_paths(root_dir: PathBuf, config_dir: PathBuf) -> Result<Self>
Creates a new storage instance with explicit data and config directories.
§Errors
Returns an error if the data or config directories cannot be created.
Sourcepub fn config_dir(&self) -> &Path
pub fn config_dir(&self) -> &Path
Returns the root configuration directory path used for descriptors
Sourcepub fn descriptor_path(&self, alias: &str) -> Result<PathBuf>
pub fn descriptor_path(&self, alias: &str) -> Result<PathBuf>
Returns the path to the descriptor TOML for a source.
§Errors
Returns an error if the alias is invalid.
Sourcepub fn save_descriptor(&self, descriptor: &SourceDescriptor) -> Result<()>
pub fn save_descriptor(&self, descriptor: &SourceDescriptor) -> Result<()>
Persist a descriptor to disk, creating parent directories if necessary.
§Errors
Returns an error if the descriptor cannot be serialized or written.
Sourcepub fn load_descriptor(&self, alias: &str) -> Result<Option<SourceDescriptor>>
pub fn load_descriptor(&self, alias: &str) -> Result<Option<SourceDescriptor>>
Load a descriptor if it exists.
§Errors
Returns an error if the descriptor cannot be read or parsed.
Sourcepub fn remove_descriptor(&self, alias: &str) -> Result<()>
pub fn remove_descriptor(&self, alias: &str) -> Result<()>
Remove descriptor file for an alias if present.
§Errors
Returns an error if the descriptor cannot be removed.
Sourcepub fn ensure_tool_dir(&self, source: &str) -> Result<PathBuf>
pub fn ensure_tool_dir(&self, source: &str) -> Result<PathBuf>
Ensures the directory for an alias exists and returns its path.
§Errors
Returns an error if the alias is invalid or the directory cannot be created.
Sourcepub fn llms_txt_path(&self, source: &str) -> Result<PathBuf>
pub fn llms_txt_path(&self, source: &str) -> Result<PathBuf>
Returns the path to the llms.txt file for a source.
§Errors
Returns an error if the alias is invalid.
Sourcepub fn llms_json_path(&self, source: &str) -> Result<PathBuf>
pub fn llms_json_path(&self, source: &str) -> Result<PathBuf>
Returns the path to the llms.json file for a source.
§Errors
Returns an error if the alias is invalid.
Sourcepub fn index_dir(&self, source: &str) -> Result<PathBuf>
pub fn index_dir(&self, source: &str) -> Result<PathBuf>
Returns the path to the search index directory for a source.
§Errors
Returns an error if the alias is invalid.
Sourcepub fn archive_dir(&self, source: &str) -> Result<PathBuf>
pub fn archive_dir(&self, source: &str) -> Result<PathBuf>
Returns the path to the archive directory for a source.
§Errors
Returns an error if the alias is invalid.
Sourcepub fn metadata_path(&self, source: &str) -> Result<PathBuf>
pub fn metadata_path(&self, source: &str) -> Result<PathBuf>
Returns the path to the metadata file for a source.
§Errors
Returns an error if the alias is invalid.
Sourcepub fn anchors_map_path(&self, source: &str) -> Result<PathBuf>
pub fn anchors_map_path(&self, source: &str) -> Result<PathBuf>
Returns the path to the anchors mapping file for a source.
§Errors
Returns an error if the alias is invalid.
Sourcepub fn save_llms_txt(&self, source: &str, content: &str) -> Result<()>
pub fn save_llms_txt(&self, source: &str, content: &str) -> Result<()>
Saves the llms.txt content for a source.
§Errors
Returns an error if the file cannot be written or renamed.
Sourcepub fn load_llms_txt(&self, source: &str) -> Result<String>
pub fn load_llms_txt(&self, source: &str) -> Result<String>
Sourcepub fn save_llms_json(&self, source: &str, data: &LlmsJson) -> Result<()>
pub fn save_llms_json(&self, source: &str, data: &LlmsJson) -> Result<()>
Saves the parsed llms.json data for a source.
§Errors
Returns an error if the JSON cannot be serialized or written.
Sourcepub fn load_llms_json(&self, source: &str) -> Result<LlmsJson>
pub fn load_llms_json(&self, source: &str) -> Result<LlmsJson>
Loads the parsed llms.json data for a source.
§Errors
Returns an error if the file cannot be read or the JSON is invalid.
Sourcepub fn save_source_metadata(
&self,
source: &str,
metadata: &Source,
) -> Result<()>
pub fn save_source_metadata( &self, source: &str, metadata: &Source, ) -> Result<()>
Saves source metadata for a source.
§Errors
Returns an error if the metadata cannot be serialized or written.
Sourcepub fn save_anchors_map(&self, source: &str, map: &AnchorsMap) -> Result<()>
pub fn save_anchors_map(&self, source: &str, map: &AnchorsMap) -> Result<()>
Save anchors remap JSON for a source.
§Errors
Returns an error if the anchors map cannot be serialized or written.
Sourcepub fn load_source_metadata(&self, source: &str) -> Result<Option<Source>>
pub fn load_source_metadata(&self, source: &str) -> Result<Option<Source>>
Loads source metadata for a source if it exists.
§Errors
Returns an error if the metadata cannot be read or parsed.
Sourcepub fn list_sources(&self) -> Vec<String>
pub fn list_sources(&self) -> Vec<String>
Lists all cached sources
Sourcepub fn clear_cache(&self) -> Result<()>
pub fn clear_cache(&self) -> Result<()>
Clears the entire cache directory, removing all sources and their data.
This is a destructive operation that cannot be undone. Use with caution.
§Errors
Returns an error if the cache directory cannot be removed or recreated.
Trait Implementations§
Source§impl RefreshStorage for Storage
impl RefreshStorage for Storage
Source§fn load_metadata(&self, alias: &str) -> Result<Source>
fn load_metadata(&self, alias: &str) -> Result<Source>
Source§fn load_llms_aliases(&self, alias: &str) -> Result<Vec<String>>
fn load_llms_aliases(&self, alias: &str) -> Result<Vec<String>>
Source§fn save_llms_txt(&self, alias: &str, content: &str) -> Result<()>
fn save_llms_txt(&self, alias: &str, content: &str) -> Result<()>
Source§fn save_llms_json(&self, alias: &str, data: &LlmsJson) -> Result<()>
fn save_llms_json(&self, alias: &str, data: &LlmsJson) -> Result<()>
Source§fn save_metadata(&self, alias: &str, metadata: &Source) -> Result<()>
fn save_metadata(&self, alias: &str, metadata: &Source) -> Result<()>
Auto Trait Implementations§
impl Freeze for Storage
impl RefUnwindSafe for Storage
impl Send for Storage
impl Sync for Storage
impl Unpin for Storage
impl UnwindSafe for Storage
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more