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 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 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.
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