pub struct PromptStorageFactory;Expand description
Factory for creating domain-scoped prompt storage.
Implementations§
Source§impl PromptStorageFactory
impl PromptStorageFactory
Sourcepub fn create_for_scope(
scope: DomainScope,
config: &Config,
) -> Result<Arc<dyn PromptStorage>>
pub fn create_for_scope( scope: DomainScope, config: &Config, ) -> Result<Arc<dyn PromptStorage>>
Creates a prompt storage for the given domain scope.
§Domain Routing
- Project:
SQLiteat~/.config/subcog/memories.db(with repo/branch facets) - User:
SQLiteat~/.config/subcog/memories.db(default) - Org:
SQLiteat~/.config/subcog/orgs/{org}/memories.db
§Arguments
scope- The domain scopeconfig- Application configuration
§Errors
Returns an error if:
- Org scope is requested but no org identifier can be resolved
- Storage backend cannot be initialized
Sourcepub fn create_for_scope_with_subcog_config(
scope: DomainScope,
config: &SubcogConfig,
) -> Result<Arc<dyn PromptStorage>>
pub fn create_for_scope_with_subcog_config( scope: DomainScope, config: &SubcogConfig, ) -> Result<Arc<dyn PromptStorage>>
Creates storage for the given scope using full subcog configuration.
Uses the storage settings from the config file when available.
§Errors
Returns an error if:
- The storage backend cannot be initialized
- Required paths or connection strings are missing
- The Redis feature is not enabled for Redis backend
Sourcefn create_project_storage(_config: &Config) -> Result<Arc<dyn PromptStorage>>
fn create_project_storage(_config: &Config) -> Result<Arc<dyn PromptStorage>>
Creates project-scoped storage (SQLite in project directory).
Sourcefn create_user_storage(_config: &Config) -> Result<Arc<dyn PromptStorage>>
fn create_user_storage(_config: &Config) -> Result<Arc<dyn PromptStorage>>
Creates user-scoped storage based on configuration.
Priority order:
SQLite(default)- Filesystem (fallback if
SQLitefails)
Note: PostgreSQL and Redis support requires explicit backend selection
via create_with_backend().
Sourcefn create_org_storage(config: &Config) -> Result<Arc<dyn PromptStorage>>
fn create_org_storage(config: &Config) -> Result<Arc<dyn PromptStorage>>
Creates org-scoped storage based on configuration.
Resolves org identifier from:
SUBCOG_ORGenvironment variable- Git remote URL (extracts org from
github.com/org/repo) - Falls back with error if no org can be resolved
Priority order:
SQLite(default)- Filesystem (fallback if
SQLitefails)
Sourcefn resolve_org_identifier(config: &Config) -> Result<String>
fn resolve_org_identifier(config: &Config) -> Result<String>
Resolves the organization identifier.
Priority:
SUBCOG_ORGenvironment variable- Git remote URL (extracts org from
github.com/org/repo)
Sourcefn extract_org_from_repo_path(path: &Path) -> Option<String>
fn extract_org_from_repo_path(path: &Path) -> Option<String>
Extracts organization from a git repository’s origin remote.
Sourcefn extract_org_from_git_url(url: &str) -> Option<String>
fn extract_org_from_git_url(url: &str) -> Option<String>
Extracts organization name from a git URL.
Supports:
https://github.com/org/repo.gitgit@github.com:org/repo.gitssh://git@github.com/org/repo.git
Sourcepub fn create_with_backend(
backend: PromptBackendType,
path: Option<PathBuf>,
connection_url: Option<String>,
) -> Result<Arc<dyn PromptStorage>>
pub fn create_with_backend( backend: PromptBackendType, path: Option<PathBuf>, connection_url: Option<String>, ) -> Result<Arc<dyn PromptStorage>>
Creates storage with an explicit backend type.
§Arguments
backend- The backend type to usepath- Path for file-based backends (repo path for git, db path forSQLite, dir for filesystem)connection_url- Connection URL for network backends (PostgreSQL, Redis)
§Errors
Returns an error if the backend cannot be initialized.
Auto Trait Implementations§
impl Freeze for PromptStorageFactory
impl RefUnwindSafe for PromptStorageFactory
impl Send for PromptStorageFactory
impl Sync for PromptStorageFactory
impl Unpin for PromptStorageFactory
impl UnwindSafe for PromptStorageFactory
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].