Skip to main content

ScopedName

Struct ScopedName 

Source
#[repr(C)]
pub struct ScopedName<Name = String> { pub scope: Name, pub name: Name, }
Expand description

Name in the format <owner>/<drop>.

Fields§

§scope: Name

The namespace of the drop.

§name: Name

The drop’s given name.

Implementations§

Source§

impl<N> ScopedName<N>

Source

pub fn new<A, B>(scope: A, name: B) -> Self
where A: Into<N>, B: Into<N>,

Creates a new instance from scope and name.

Source

pub fn parse<A, NE>(name: A) -> Result<Self, ParseError<NE>>
where A: TryInto<Self, Error = ParseError<NE>>,

Attempts to create a new instance by parsing name.

Source

pub fn cast<A>(self) -> ScopedName<A>
where N: Into<A>,

Converts self into a new ScopedName by performing an Into conversion over all fields.

Source

pub fn try_cast<A>(self) -> Result<ScopedName<A>, ParseError<N::Error>>
where N: TryInto<A>,

Converts self into a new Query by performing an Into conversion over all fields.

Source

pub fn as_ref(&self) -> ScopedName<&N>

Takes shared references to the fields of this name.

Source

pub fn to_ref<A>(&self) -> ScopedName<&A>
where N: AsRef<A>, A: ?Sized,

Takes a shared reference to the fields of this name as type A.

Source

pub fn as_mut(&mut self) -> ScopedName<&mut N>

Takes mutable references to the fields of this name.

Source

pub fn to_mut<A>(&mut self) -> ScopedName<&mut A>
where N: AsMut<A>, A: ?Sized,

Takes a mutable references to the fields of this name as type A.

Source

pub fn map<A, F>(self, f: F) -> ScopedName<A>
where F: FnMut(N) -> A,

Creates a new ScopedName by mapping the function over the fields of self.

Source

pub fn into_query(self) -> Query<N>

Converts self into a Query.

Source

pub fn into_query_with<V>(self, version: V) -> Query<N, V>

Converts self into a Query with the specified version.

Source

pub fn as_names_array(&self) -> &[N; 2]

Converts self into an array of names.

Source

pub fn as_names_slice(&self) -> &[N]

Converts self into a slice of names.

Source§

impl<'n, N: ?Sized> ScopedName<&'n N>

Source

pub fn cloned(&self) -> ScopedName<N>
where N: Clone,

Returns the result of calling Clone::clone on the fields of self.

Source

pub fn to_owned(&self) -> ScopedName<N::Owned>
where N: ToOwned,

Returns the result of calling ToOwned::to_owned on the fields of self.

§Examples
use oceanpkg::drop::name::ScopedName;

let name:  ScopedName<&str>   = ScopedName::new("core", "wget");
let owned: ScopedName<String> = name.to_owned();

assert_eq!(name, owned);
Source§

impl<'n> ScopedName<&'n Name>

Source

pub const fn core(name: &'n Name) -> Self

Creates a new instance in the core namespace.

Source

pub const fn ocean(name: &'n Name) -> Self

Creates a new instance in the ocean namespace.

Source

pub fn from_pair<S, N>( scope: &'n S, name: &'n N, ) -> Result<Self, ParseError<ValidateError>>
where S: ?Sized + AsRef<[u8]>, N: ?Sized + AsRef<[u8]>,

Creates a new instance by verifying scope and name.

Source

pub unsafe fn from_pair_unchecked<S, N>(scope: &'n S, name: &'n N) -> Self
where S: ?Sized + AsRef<[u8]>, N: ?Sized + AsRef<[u8]>,

Creates a new instance without attempting to verify scope or name.

Trait Implementations§

Source§

impl<Name: Clone> Clone for ScopedName<Name>

Source§

fn clone(&self) -> ScopedName<Name>

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<Name: Debug> Debug for ScopedName<Name>

Source§

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

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

impl<'de> Deserialize<'de> for ScopedName

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<N: Display> Display for ScopedName<N>

Source§

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

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

impl<A, B: Into<A>> From<[B; 2]> for ScopedName<A>

Source§

fn from([scope, name]: [B; 2]) -> Self

Converts to this type from the input type.
Source§

impl<N, A, B> From<(A, B)> for ScopedName<N>
where A: Into<N>, B: Into<N>,

Source§

fn from((scope, name): (A, B)) -> Self

Converts to this type from the input type.
Source§

impl<N, V> From<ScopedName<N>> for Query<N, V>

Source§

fn from(n: ScopedName<N>) -> Self

Converts to this type from the input type.
Source§

impl<Name: Hash> Hash for ScopedName<Name>

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<Name: Ord> Ord for ScopedName<Name>

Source§

fn cmp(&self, other: &ScopedName<Name>) -> 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<A: AsRef<str>> PartialEq<&str> for ScopedName<A>

Source§

fn eq(&self, s: &&str) -> 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<A: AsRef<str>> PartialEq<ScopedName<A>> for &str

Source§

fn eq(&self, n: &ScopedName<A>) -> 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<A: AsRef<str>> PartialEq<ScopedName<A>> for str

Source§

fn eq(&self, n: &ScopedName<A>) -> 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<A, B> PartialEq<ScopedName<B>> for ScopedName<A>
where A: PartialEq<B>,

Source§

fn eq(&self, other: &ScopedName<B>) -> 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<A: AsRef<str>> PartialEq<str> for ScopedName<A>

Source§

fn eq(&self, s: &str) -> 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<Name: PartialOrd> PartialOrd for ScopedName<Name>

Source§

fn partial_cmp(&self, other: &ScopedName<Name>) -> 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<N> Serialize for ScopedName<N>
where ScopedName<N>: Display,

Source§

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

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

impl<'a, N> TryFrom<&'a str> for ScopedName<N>
where &'a str: TryInto<N>,

Source§

type Error = ParseError<<&'a str as TryInto<N>>::Error>

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

fn try_from(name: &'a str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<Name: Copy> Copy for ScopedName<Name>

Source§

impl<Name: Eq> Eq for ScopedName<Name>

Auto Trait Implementations§

§

impl<Name> Freeze for ScopedName<Name>
where Name: Freeze,

§

impl<Name> RefUnwindSafe for ScopedName<Name>
where Name: RefUnwindSafe,

§

impl<Name> Send for ScopedName<Name>
where Name: Send,

§

impl<Name> Sync for ScopedName<Name>
where Name: Sync,

§

impl<Name> Unpin for ScopedName<Name>
where Name: Unpin,

§

impl<Name> UnsafeUnpin for ScopedName<Name>
where Name: UnsafeUnpin,

§

impl<Name> UnwindSafe for ScopedName<Name>
where Name: UnwindSafe,

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