[−][src]Struct oceanpkg::drop::name::query::Query
A drop lookup in the form (<scope>/)?<name>(@<version>)?
.
By default, String
is used for the generic Name
and Version
types.
When performing zero-copy parsing, it is recommended to use Query<&str>
.
Fields
scope: Option<Name>
The drop's owner.
name: Name
The drop's name.
version: Option<Version>
The drop's version requirement.
Methods
impl<N, V> Query<N, V>
[src]
pub fn new<A, B, C>(scope: A, name: B, version: C) -> Self where
A: Into<N>,
B: Into<N>,
C: Into<V>,
[src]
A: Into<N>,
B: Into<N>,
C: Into<V>,
Creates a new Query
instance with scope
, name
, and version
.
Examples
This serves as a convenience to not need to deal with explicitly
wrapping types with Some
.
use oceanpkg::drop::name::Query; let query = Query::<&str>::new("core", "wget", "1.20"); assert_eq!(query.to_string(), "core/wget@1.20");
pub fn parse<Q, NE, VE>(query: Q) -> Result<Self, ParseError<NE, VE>> where
Q: TryInto<Self, Error = ParseError<NE, VE>>,
[src]
Q: TryInto<Self, Error = ParseError<NE, VE>>,
Attempts to create a new instance by strictly parsing name
.
pub fn parse_liberal<'a>(query: &'a str) -> Self where
&'a str: Into<N>,
&'a str: Into<V>,
[src]
&'a str: Into<N>,
&'a str: Into<V>,
Creates a new instance by parsing query
in a non-strict manner.
Examples
use oceanpkg::drop::name::Query; let scope = "core"; let name = "ruby"; let version = "2.6"; let query_string = format!("{}/{}@{}", scope, name, version); let query = Query::<&str>::parse_liberal(&query_string); assert_eq!(query.scope, Some(scope)); assert_eq!(query.name, name); assert_eq!(query.version, Some(version)); assert_eq!(query.to_string(), query_string);
pub fn cast<A, B>(self) -> Query<A, B> where
N: Into<A>,
V: Into<B>,
[src]
N: Into<A>,
V: Into<B>,
Converts self
into a new Query
by performing an Into
conversion
over all fields.
pub fn try_cast<A, B>(
self
) -> Result<Query<A, B>, ParseError<N::Error, V::Error>> where
N: TryInto<A>,
V: TryInto<B>,
[src]
self
) -> Result<Query<A, B>, ParseError<N::Error, V::Error>> where
N: TryInto<A>,
V: TryInto<B>,
Converts self
into a new Query
by performing an Into
conversion
over all fields.
pub fn as_ref(&self) -> Query<&N, &V>
[src]
Takes a shared reference to the fields of this query.
See Query::as_mut
for the mutable equivalent.
pub fn to_ref<A>(&self) -> Query<&A> where
N: AsRef<A>,
V: AsRef<A>,
A: ?Sized,
[src]
N: AsRef<A>,
V: AsRef<A>,
A: ?Sized,
Takes a shared reference to the fields of this query as type A
.
See Query::to_mut
for the mutable equivalent.
Examples
use oceanpkg::drop::name::Query; let query: Query<String> = // let by_ref: Query<&str> = query.to_ref(); assert_eq!(query, by_ref);
pub fn as_mut(&mut self) -> Query<&mut N, &mut V>
[src]
Takes a mutable reference to the fields of this query.
See Query::as_ref
for the immutable equivalent.
pub fn to_mut<A>(&mut self) -> Query<&mut A> where
N: AsMut<A>,
V: AsMut<A>,
A: ?Sized,
[src]
N: AsMut<A>,
V: AsMut<A>,
A: ?Sized,
Takes a mutable reference to the fields of this query as type A
.
See Query::to_ref
for the immutable equivalent.
pub fn scoped_name(&self) -> Option<ScopedName<&N>>
[src]
Returns the scoped name for self
if scope
exists.
pub fn cmp_version<A, B>(&self, other: &Query<A, B>) -> Option<Ordering> where
V: PartialOrd<B>,
[src]
V: PartialOrd<B>,
Performs a partial version comparison between self
and other
.
Returns None
if:
- One version is
Some
and the other isSome
. <V as PartialOrd<B>>::partial_cmp
returnsNone
.
pub fn file_name(&self) -> String where
N: Display,
V: Display,
[src]
N: Display,
V: Display,
Returns the name of self
formatted for the filesystem.
pub fn tarball_name(&self) -> String where
N: Display,
V: Display,
[src]
N: Display,
V: Display,
Returns the name of self
packaged as a tarball.
pub fn join_to_url(&self, url: &Url) -> Result<Url, ParseError> where
N: Display,
V: AsRef<str>,
[src]
N: Display,
V: AsRef<str>,
Returns a new Url
with the fields of self
appended.
Examples
If scope
is empty, it is replaced with core
.
use oceanpkg::drop::name::Query; use url::Url; let query = "wget@1.20"; let query = Query::<&str>::parse_liberal(query); let url = Url::parse("https://www.oceanpkg.org").unwrap(); let url = query.join_to_url(&url).unwrap(); assert_eq!(url.as_str(), "https://www.oceanpkg.org/u/core/p/wget?version=1.20");
impl<'n, 'v, N: ?Sized, V: ?Sized> Query<&'n N, &'v V>
[src]
pub fn to_owned(&self) -> Query<N::Owned, V::Owned> where
N: ToOwned,
V: ToOwned,
[src]
N: ToOwned,
V: ToOwned,
Returns the result of calling ToOwned::to_owned
on the fields of
self
.
Examples
use oceanpkg::drop::name::Query; let query: Query<&str> = Query::new("core", "wget", "*"); let owned: Query<String> = query.to_owned(); assert_eq!(query, owned);
Trait Implementations
impl<Name: Clone, Version: Clone> Clone for Query<Name, Version>
[src]
impl<Name: Copy, Version: Copy> Copy for Query<Name, Version>
[src]
impl<Name: Debug, Version: Debug> Debug for Query<Name, Version>
[src]
impl<'de, N, V, NE, VE> Deserialize<'de> for Query<N, V> where
&'a str: TryInto<Query<N, V>, Error = ParseError<NE, VE>>,
ParseError<NE, VE>: Display,
[src]
&'a str: TryInto<Query<N, V>, Error = ParseError<NE, VE>>,
ParseError<NE, VE>: Display,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
impl<N: Display, V: Display> Display for Query<N, V>
[src]
impl<Name: Eq, Version: Eq> Eq for Query<Name, Version>
[src]
impl<N, V> From<ScopedName<N>> for Query<N, V>
[src]
fn from(n: ScopedName<N>) -> Self
[src]
impl<Name: Hash, Version: Hash> Hash for Query<Name, Version>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<Name: Ord, Version: Ord> Ord for Query<Name, Version>
[src]
fn cmp(&self, other: &Query<Name, Version>) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<A, B, X, Y> PartialEq<Query<X, Y>> for Query<A, B> where
A: PartialEq<X>,
B: PartialEq<Y>,
[src]
A: PartialEq<X>,
B: PartialEq<Y>,
fn eq(&self, other: &Query<X, Y>) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<Name: PartialOrd, Version: PartialOrd> PartialOrd<Query<Name, Version>> for Query<Name, Version>
[src]
fn partial_cmp(&self, other: &Query<Name, Version>) -> Option<Ordering>
[src]
fn lt(&self, other: &Query<Name, Version>) -> bool
[src]
fn le(&self, other: &Query<Name, Version>) -> bool
[src]
fn gt(&self, other: &Query<Name, Version>) -> bool
[src]
fn ge(&self, other: &Query<Name, Version>) -> bool
[src]
impl<N, V> Serialize for Query<N, V> where
Query<N, V>: Display,
[src]
Query<N, V>: Display,
impl<Name, Version> StructuralEq for Query<Name, Version>
[src]
impl<'a, N, V> TryFrom<&'a str> for Query<N, V> where
&'a str: TryInto<N>,
&'a str: TryInto<V>,
[src]
&'a str: TryInto<N>,
&'a str: TryInto<V>,
Auto Trait Implementations
impl<Name, Version> RefUnwindSafe for Query<Name, Version> where
Name: RefUnwindSafe,
Version: RefUnwindSafe,
Name: RefUnwindSafe,
Version: RefUnwindSafe,
impl<Name, Version> Send for Query<Name, Version> where
Name: Send,
Version: Send,
Name: Send,
Version: Send,
impl<Name, Version> Sync for Query<Name, Version> where
Name: Sync,
Version: Sync,
Name: Sync,
Version: Sync,
impl<Name, Version> Unpin for Query<Name, Version> where
Name: Unpin,
Version: Unpin,
Name: Unpin,
Version: Unpin,
impl<Name, Version> UnwindSafe for Query<Name, Version> where
Name: UnwindSafe,
Version: UnwindSafe,
Name: UnwindSafe,
Version: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,