Struct QualifiedName

Source
pub struct QualifiedName(/* private fields */);
Expand description

A qualified name, consisting of a sequence of name segments.

A qualified name is a sequence of segments that unambiguously names an element in a set, or a family of sets, or a family of family of sets, and so on. For example, a qualified name with three segments can be constructed as

let name: QualifiedName = ["foo", "bar", "baz"].map(NameSegment::from).into();
assert_eq!(name.to_string(), "foo.bar.baz");

§Data structure

At this time, a qualified name is stored simply as a vector of name segments. Various optimizations could be considered, such as an Rc<[NameSegment]> or, since qualified names tend to have only a few segments, a SmallVec<[NameSegment; n]> for some choice of n. These will be considered premature optimizations until there is good evidence in favor of them.

§Serialization

To simplify their use in JavaScript, qualified name are serialized as flat strings with segments separated by periods. Human-readable names are quoted with backticks regardless of whether they contain whitespace, which makes parsing easier. Note that the display format is different from the serialization format.

Implementations§

Source§

impl QualifiedName

Source

pub fn single(segment: NameSegment) -> Self

Constructs a qualified name with a single segment.

Source

pub fn segments(&self) -> impl Iterator<Item = &NameSegment>

Iterates over the segments of the qualified name.

Source

pub fn only(&self) -> Option<NameSegment>

Gets the segment from a qualified name with only one segment.

Source

pub fn serialize_string(&self) -> String

Serializes the qualified name into a string.

Source

pub fn deserialize_str(input: &str) -> Result<Self, String>

Deserializes a qualified name from a string.

Trait Implementations§

Source§

impl Clone for QualifiedName

Source§

fn clone(&self) -> QualifiedName

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for QualifiedName

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for QualifiedName

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for QualifiedName

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&str> for QualifiedName

Source§

fn from(name: &str) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<[&str; N]> for QualifiedName

Source§

fn from(segments: [&str; N]) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<[NameSegment; N]> for QualifiedName

Source§

fn from(segments: [NameSegment; N]) -> Self

Converts to this type from the input type.
Source§

impl<const N: usize> From<[Uuid; N]> for QualifiedName

Source§

fn from(segments: [Uuid; N]) -> Self

Converts to this type from the input type.
Source§

impl From<QualifiedName> for JsValue

Source§

fn from(value: QualifiedName) -> Self

Converts to this type from the input type.
Source§

impl From<QualifiedName> for ModalMor

Source§

fn from(value: QualifiedName) -> Self

Converts to this type from the input type.
Source§

impl From<QualifiedName> for ModalOb

Source§

fn from(value: QualifiedName) -> Self

Converts to this type from the input type.
Source§

impl From<QualifiedName> for ModalOp

Source§

fn from(value: QualifiedName) -> Self

Converts to this type from the input type.
Source§

impl From<QualifiedName> for TabMor

Source§

fn from(value: QualifiedName) -> Self

Converts to this type from the input type.
Source§

impl From<QualifiedName> for TabEdge

Source§

fn from(value: QualifiedName) -> Self

Converts to this type from the input type.
Source§

impl From<QualifiedName> for TabMorType

Source§

fn from(value: QualifiedName) -> Self

Converts to this type from the input type.
Source§

impl From<QualifiedName> for TabOb

Source§

fn from(value: QualifiedName) -> Self

Converts to this type from the input type.
Source§

impl From<QualifiedName> for TabObType

Source§

fn from(value: QualifiedName) -> Self

Converts to this type from the input type.
Source§

impl From<Ustr> for QualifiedName

Source§

fn from(name: Ustr) -> Self

Converts to this type from the input type.
Source§

impl From<Uuid> for QualifiedName

Source§

fn from(id: Uuid) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<NameSegment>> for QualifiedName

Source§

fn from(value: Vec<NameSegment>) -> Self

Converts to this type from the input type.
Source§

impl FromWasmAbi for QualifiedName
where Self: DeserializeOwned,

Source§

type Abi = <JsType as FromWasmAbi>::Abi

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: Self::Abi) -> Self

Recover a Self from Self::Abi. Read more
Source§

impl Hash for QualifiedName

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntoWasmAbi for QualifiedName

Source§

type Abi = <JsType as IntoWasmAbi>::Abi

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> Self::Abi

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl OptionFromWasmAbi for QualifiedName
where Self: DeserializeOwned,

Source§

fn is_none(js: &Self::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
Source§

impl OptionIntoWasmAbi for QualifiedName

Source§

fn none() -> Self::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
Source§

impl Ord for QualifiedName

Source§

fn cmp(&self, other: &QualifiedName) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for QualifiedName

Source§

fn eq(&self, other: &QualifiedName) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for QualifiedName

Source§

fn partial_cmp(&self, other: &QualifiedName) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl RefFromWasmAbi for QualifiedName
where Self: DeserializeOwned,

Source§

type Abi = <JsType as RefFromWasmAbi>::Abi

The Wasm ABI type references to Self are recovered from.
Source§

type Anchor = SelfOwner<QualifiedName>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don’t persist beyond one function call, and so that they remain anonymous.
Source§

unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor

Recover a Self::Anchor from Self::Abi. Read more
Source§

impl Serialize for QualifiedName

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Tsify for QualifiedName

Source§

const DECL: &'static str = "/**\n * A qualified name, consisting of a sequence of [name segments](NameSegment).\\n\\nA qualified name is a sequence of segments that unambiguously names an element\\nin a set, or a family of sets, or a family of family of sets, and so on. For\\nexample, a qualified name with three segments can be constructed as\\n\\n```\\n# use catlog::zero::qualified::*;\\nlet name: QualifiedName = [\\\"foo\\\", \\\"bar\\\", \\\"baz\\\"].map(NameSegment::from).into();\\nassert_eq!(name.to_string(), \\\"foo.bar.baz\\\");\\n```\\n\\n# Data structure\\n\\nAt this time, a qualified name is stored simply as a vector of name segments.\\nVarious optimizations could be considered, such as an `Rc<[NameSegment]>` or,\\nsince qualified names tend to have only a few segments, a\\n`SmallVec<[NameSegment; n]>` for some choice of `n`. These will be considered\\npremature optimizations until there is good evidence in favor of them.\\n\\n# Serialization\\n\\nTo simplify their use in JavaScript, qualified name are serialized as flat\\nstrings with segments separated by periods. Human-readable names are quoted with\\nbackticks regardless of whether they contain whitespace, which makes parsing\\neasier. Note that the [display](Display) format is different from the\\nserialization format.\\n \n */\nexport type QualifiedName = string;"

Source§

const SERIALIZATION_CONFIG: SerializationConfig

Source§

type JsType = JsType

§

fn into_js(&self) -> Result<Self::JsType, Error>
where Self: Serialize,

§

fn from_js<T>(js: T) -> Result<Self, Error>
where T: Into<JsValue>, Self: DeserializeOwned,

Source§

impl VectorFromWasmAbi for QualifiedName
where Self: DeserializeOwned,

Source§

type Abi = <JsType as VectorFromWasmAbi>::Abi

Source§

unsafe fn vector_from_abi(js: Self::Abi) -> Box<[Self]>

Source§

impl VectorIntoWasmAbi for QualifiedName

Source§

type Abi = <JsType as VectorIntoWasmAbi>::Abi

Source§

fn vector_into_abi(vector: Box<[Self]>) -> Self::Abi

Source§

impl WasmDescribe for QualifiedName

Source§

impl WasmDescribeVector for QualifiedName

Source§

impl Eq for QualifiedName

Source§

impl StructuralPartialEq for QualifiedName

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ReturnWasmAbi for T
where T: IntoWasmAbi,

Source§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
Source§

fn return_abi(self) -> <T as ReturnWasmAbi>::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,