pub struct Resolver { /* private fields */ }Expand description
The NAP resolver — resolves URIs to manifests or subtrees.
Implementations§
Source§impl Resolver
impl Resolver
Sourcepub fn new(base_path: &Path) -> Self
pub fn new(base_path: &Path) -> Self
Create a resolver that looks for repository repos under base_path.
Uses LoreBackend::from_env() by default when a version-control
backend is configured for base_path (i.e. a valid provider.toml
exists). Otherwise repositories are opened in unversioned mode. For
testing, use Resolver::with_vcs_factory() with a mock backend.
Uses ResolveConfig::default() — meaning default_branch is
None. In versioned mode any resolve that omits both branch and
commit will fail with NapError::NoDefaultBranch; in unversioned
mode such a resolve reads the current filesystem state.
§Example layout
base_path/
├── toystory/ ← repository repo
├── toystory/ ← repository repo
└── marvel/ ← repository repoSourcepub fn with_vcs_factory(
base_path: &Path,
factory: fn() -> Box<dyn VcsBackend>,
config: ResolveConfig,
) -> Self
pub fn with_vcs_factory( base_path: &Path, factory: fn() -> Box<dyn VcsBackend>, config: ResolveConfig, ) -> Self
Create a resolver with a custom VCS backend factory and config.
Repositories are always opened in versioned mode.
Sourcepub fn with_source(self, source: ResolveSource) -> Self
pub fn with_source(self, source: ResolveSource) -> Self
Override the resolver’s default source. Primarily useful to callers that need an explicit local working-tree read.
Sourcepub fn resolve(
&self,
uri_str: &str,
options: &ResolveOptions,
) -> Result<ResolveResult, NapError>
pub fn resolve( &self, uri_str: &str, options: &ResolveOptions, ) -> Result<ResolveResult, NapError>
Resolve a NAP URI string with options.
§Examples
// Full manifest
resolver.resolve("nap://toystory/character/woody", &Default::default())
// Without scheme (auto-normalized)
resolver.resolve("toystory/character/woody", &Default::default())
// With branch
resolver.resolve("nap://toystory/character/woody", &ResolveOptions {
branch: Some("canon".to_string()),
..Default::default()
})
// With fragment query (via URI)
resolver.resolve("nap://toystory/character/woody#references.appears_in", &Default::default())Sourcepub async fn presign_representation(
&self,
uri_str: &str,
representation_name: &str,
options: &PresignOptions,
) -> Result<PresignedRepresentation, NapError>
pub async fn presign_representation( &self, uri_str: &str, representation_name: &str, options: &PresignOptions, ) -> Result<PresignedRepresentation, NapError>
Create a time-limited public URL for a direct, committed representation.
uri_str identifies the entity (for example,
25th-chapter/character/nathan-gunn, with an optional nap:// prefix).
representation_name is its manifest representation key, such as item.
The representation URI is relative to the entity’s asset directory.
The returned URL is a bearer capability. Callers must not log it or
persist it beyond expires_at.
Sourcepub fn resolve_uri(
&self,
uri: &NapUri,
options: &ResolveOptions,
) -> Result<ResolveResult, NapError>
pub fn resolve_uri( &self, uri: &NapUri, options: &ResolveOptions, ) -> Result<ResolveResult, NapError>
Resolve a parsed NAP URI with options.
Sourcepub fn query(&self, uri_str: &str, path: &str) -> Result<Value, NapError>
pub fn query(&self, uri_str: &str, path: &str) -> Result<Value, NapError>
Convenience: query a specific path on a URI.
Sourcepub fn list_repositories(&self) -> Result<Vec<String>, NapError>
pub fn list_repositories(&self) -> Result<Vec<String>, NapError>
List all repositories available.
Sourcepub fn list_remote_entities(
&self,
repository: &str,
entity_type: &EntityType,
) -> Result<Vec<String>, NapError>
pub fn list_remote_entities( &self, repository: &str, entity_type: &EntityType, ) -> Result<Vec<String>, NapError>
List entity YAMLs from the default branch of the configured Lore server.
Sourcepub fn list_remote_manifest_paths(
&self,
repository: &str,
) -> Result<Vec<String>, NapError>
pub fn list_remote_manifest_paths( &self, repository: &str, ) -> Result<Vec<String>, NapError>
List repository-relative entity manifest paths from the default branch.
pub fn list_remote_branches( &self, repository: &str, ) -> Result<Vec<String>, NapError>
pub fn remote_head_hash(&self, repository: &str) -> Result<String, NapError>
pub fn remote_history( &self, uri: &NapUri, limit: usize, ) -> Result<Vec<CommitInfo>, NapError>
Auto Trait Implementations§
impl Freeze for Resolver
impl RefUnwindSafe for Resolver
impl Send for Resolver
impl Sync for Resolver
impl Unpin for Resolver
impl UnsafeUnpin for Resolver
impl UnwindSafe for Resolver
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request