pub struct Name { /* private fields */ }Expand description
An owned name stores the name, namespace and prefix as owned strings.
An owned name is handy when you don’t want to depend on Xot, or for debugging.
It cannot be used to create elements directly, but you can turn this into a
CreateName using OwnedName::to_create and a RefName using
OwnedName::to_ref.
You can access name string information using the NameStrInfo trait.
If you enable the serde feature it can be serialized and deserialized.
Implementations§
Source§impl OwnedName
impl OwnedName
Sourcepub fn new(local_name: String, namespace: String, prefix: String) -> OwnedName
pub fn new(local_name: String, namespace: String, prefix: String) -> OwnedName
Create a new owned name.
Sourcepub fn namespaced(
local_name: String,
namespace: String,
prefix_lookup: impl Fn(&str) -> Option<String>,
) -> Result<OwnedName, Error>
pub fn namespaced( local_name: String, namespace: String, prefix_lookup: impl Fn(&str) -> Option<String>, ) -> Result<OwnedName, Error>
Create a new name in a namespace, look up prefix information.
Sourcepub fn prefixed(
prefix: &str,
local_name: &str,
lookup_namespace: impl Fn(&str) -> Option<String>,
) -> Result<OwnedName, Error>
pub fn prefixed( prefix: &str, local_name: &str, lookup_namespace: impl Fn(&str) -> Option<String>, ) -> Result<OwnedName, Error>
Create a new owned name from a prefix and a name.
Sourcepub fn parse_full_name(
full_name: &str,
lookup_namespace: impl Fn(&str) -> Option<String>,
) -> Result<OwnedName, Error>
pub fn parse_full_name( full_name: &str, lookup_namespace: impl Fn(&str) -> Option<String>, ) -> Result<OwnedName, Error>
Given a fullname (with potentially a prefix), construct an XmlNameOwned
This requires a function that can look up the namespace for a prefix.
Sourcepub fn with_suffix(self) -> OwnedName
pub fn with_suffix(self) -> OwnedName
Convert this name into a name adding a * suffix.
This can be useful to help generate unique names.
Sourcepub fn with_default_namespace(self, namespace: &str) -> OwnedName
pub fn with_default_namespace(self, namespace: &str) -> OwnedName
Convert this name into a name that’s in a particular namespace.
This only changes the namespace if there is an empty prefix and the namespace is not set (the empty string).
Sourcepub fn in_default_namespace(&self) -> bool
pub fn in_default_namespace(&self) -> bool
Name is in a namespace but without a prefix, so it’s in a default namespace.
Sourcepub fn to_ref<'a>(&self, xot: &'a mut Xot) -> RefName<'a>
pub fn to_ref<'a>(&self, xot: &'a mut Xot) -> RefName<'a>
Create a new RefName from this owned name.
Sourcepub fn maybe_to_ref<'a>(&self, xot: &'a Xot) -> Option<RefName<'a>>
pub fn maybe_to_ref<'a>(&self, xot: &'a Xot) -> Option<RefName<'a>>
Create a new RefName only if names already exists in Xot.
If the local name and namespace don’t exist in Xot, returns None.
This lets you pass in an immutable reference to Xot, unlike
Owned::to_ref.
Ignores prefix information - even if the prefix doesn’t exist, we still get a ref name, just without a prefix. This is because the prefix information is irrelevant for comparison.
Otherwise, returns None.
Sourcepub fn to_create(&self, xot: &mut Xot) -> CreateName
pub fn to_create(&self, xot: &mut Xot) -> CreateName
Create a new CreateName name from this owned name.
This disregards the prefix information.
Trait Implementations§
Source§impl NameStrInfo for OwnedName
impl NameStrInfo for OwnedName
Source§impl WithSpan for OwnedName
impl WithSpan for OwnedName
fn with_span(self, span: SimpleSpan) -> Spanned<Self>
fn with_empty_span(self) -> Spanned<Self>
impl Eq for OwnedName
Auto Trait Implementations§
impl Freeze for OwnedName
impl RefUnwindSafe for OwnedName
impl Send for OwnedName
impl Sync for OwnedName
impl Unpin for OwnedName
impl UnwindSafe for OwnedName
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
key and return true if they are equal.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