pub struct NapUri {
pub universe: String,
pub entity_type: EntityType,
pub entity_id: String,
pub fragment: Option<String>,
}Expand description
A parsed NAP URI representing a narrative resource identity.
§Examples
use nap_core::uri::NapUri;
let uri: NapUri = "nap://starwars/character/lukeskywalker#references.appears_in"
.parse()
.unwrap();
assert_eq!(uri.universe, "starwars");
assert_eq!(uri.entity_type, nap_core::types::EntityType::Character);
assert_eq!(uri.entity_id, "lukeskywalker");
assert_eq!(uri.fragment.as_deref(), Some("references.appears_in"));Fields§
§universe: StringThe fictional universe (repository). e.g., "starwars", "toystory".
entity_type: EntityTypeThe kind of entity being addressed.
entity_id: StringThe entity’s identifier (slug). e.g., "lukeskywalker", "tatooine".
fragment: Option<String>Optional fragment for subtree queries. e.g., "appearances.audienceVotes".
Populated from the # portion of the URI.
Implementations§
Source§impl NapUri
impl NapUri
Sourcepub fn new(
universe: impl Into<String>,
entity_type: EntityType,
entity_id: impl Into<String>,
) -> Self
pub fn new( universe: impl Into<String>, entity_type: EntityType, entity_id: impl Into<String>, ) -> Self
Construct a new NAP URI without a fragment.
Sourcepub fn with_fragment(
universe: impl Into<String>,
entity_type: EntityType,
entity_id: impl Into<String>,
fragment: impl Into<String>,
) -> Self
pub fn with_fragment( universe: impl Into<String>, entity_type: EntityType, entity_id: impl Into<String>, fragment: impl Into<String>, ) -> Self
Construct a NAP URI with a fragment query path.
Sourcepub fn identity(&self) -> String
pub fn identity(&self) -> String
Returns the canonical URI string WITHOUT the fragment. This is the resource identity — fragments are query concerns.
Sourcepub fn manifest_path(&self) -> String
pub fn manifest_path(&self) -> String
Returns the relative filesystem path for this entity’s manifest within a universe repository.
e.g., "characters/lukeskywalker.yaml" or "universe.yaml" for world.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for NapUri
impl<'de> Deserialize<'de> for NapUri
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for NapUri
impl StructuralPartialEq for NapUri
Auto Trait Implementations§
impl Freeze for NapUri
impl RefUnwindSafe for NapUri
impl Send for NapUri
impl Sync for NapUri
impl Unpin for NapUri
impl UnsafeUnpin for NapUri
impl UnwindSafe for NapUri
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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>
Converts
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>
Converts
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