QueryDatabase

Struct QueryDatabase 

Source
pub struct QueryDatabase<'a, Querier> { /* private fields */ }
Expand description

Database to lookup queriers from their package names.

This type of database is designed for repository-unaware use cases such as:

  • Local packages: Packages that have been installed into the system.
  • Single repository archive.
  • Merging multiple repository archives where duplications don’t exist.

Implementations§

Source§

impl<'a, Querier: ShouldReuse> QueryDatabase<'a, Querier>

Source

pub fn extend<QuerierIter>( &mut self, queriers: QuerierIter, ) -> Result<(), InsertError>
where Querier: Query<'a>, QuerierIter: IntoIterator<Item = Querier>,

Extend the database with an iterator of immutable queriers of desc files.

Old queriers which occupied the same name as some of the new queriers would be replaced.

Source

pub fn extend_mut<QuerierIter>( &mut self, queriers: QuerierIter, ) -> Result<(), InsertError>
where Querier: QueryMut<'a>, QuerierIter: IntoIterator<Item = Querier>,

Extend the database with an iterator of mutable queriers of desc files.

Old queriers which occupied the same name as some of the new queriers would be replaced.

Source

pub fn extend_newer<QuerierIter>( &mut self, queriers: QuerierIter, ) -> Result<(), InsertNewerError<'_>>
where Querier: Query<'a>, QuerierIter: IntoIterator<Item = Querier>,

Extend the database with an iterator of immutable queriers of desc files that don’t share the same name as an existing querier with a newer-or-equal package version.

Source

pub fn extend_newer_mut<QuerierIter>( &mut self, queriers: QuerierIter, ) -> Result<(), InsertNewerError<'_>>
where Querier: QueryMut<'a>, QuerierIter: IntoIterator<Item = Querier>,

Extend the database with an iterator of mutable queriers of desc files that don’t share the same name as an existing querier with a newer-or-equal package version.

Source§

impl<Querier> QueryDatabase<'_, Querier>

Source

pub fn get(&self, name: Name<'_>) -> Option<&Querier>

Get an immutable reference to a querier by package name.

Source

pub fn get_mut(&mut self, name: Name<'_>) -> Option<&mut Querier>

Get a mutable reference to a querier by package name.

Source§

impl<'a, Querier: ShouldReuse> QueryDatabase<'a, Querier>

Source

pub fn insert( &mut self, querier: Querier, ) -> Result<Option<Querier>, InsertError>
where Querier: Query<'a>,

Add an immutable querier of a desc file to the database.

If an older querier already occupied the same name, it will be returned inside Ok(Some(_)).

Source

pub fn insert_mut( &mut self, querier: Querier, ) -> Result<Option<Querier>, InsertError>
where Querier: QueryMut<'a>,

Add a mutable querier of a desc file to the database.

If an older querier already occupied the same name, it will be returned inside Ok(Some(_)).

Source§

impl<'a, Querier: ShouldReuse> QueryDatabase<'a, Querier>

Source

pub fn insert_newer( &mut self, querier: Querier, ) -> Result<InsertNewerReturn<Querier>, InsertNewerError<'a>>
where Querier: Query<'a>,

Add an immutable querier of a desc file to the database unless the entry was already occupied by a querier whose package version is not older than the provided querier.

Source

pub fn insert_newer_mut( &mut self, querier: Querier, ) -> Result<InsertNewerReturn<Querier>, InsertNewerError<'a>>
where Querier: QueryMut<'a>,

Add a mutable querier of a desc file to the database unless the entry was already occupied by a querier whose package version is not older than the provided querier.

Source§

impl<'a, Querier> QueryDatabase<'a, Querier>

Source

pub fn entries(&self) -> Entries<'_, 'a, Querier>

Get an iterator over all pairs of package names and immutable queriers.

Source

pub fn entries_mut(&mut self) -> EntriesMut<'_, 'a, Querier>

Get an iterator over all pairs of package names and mutable queriers.

Source§

impl<'a, Querier: ShouldReuse> QueryDatabase<'a, Querier>

Source

pub fn from_queriers<QuerierIter>( queriers: QuerierIter, ) -> Result<Self, InsertError>
where Querier: Query<'a>, QuerierIter: IntoIterator<Item = Querier>,

Construct a database with an iterator of immutable queriers of desc files.

If there are collisions between queriers in name, the later querier would override the earlier.

Source

pub fn from_queriers_mut<QuerierIter>( queriers: QuerierIter, ) -> Result<Self, InsertError>
where Querier: QueryMut<'a>, QuerierIter: IntoIterator<Item = Querier>,

Construct a database with an iterator of mutable queriers of desc files.

If there are collisions between queriers in name, the later querier would override the earlier.

Source

pub fn from_newer_queriers<QuerierIter>( queriers: QuerierIter, ) -> Result<Self, InsertNewerError<'a>>
where Querier: Query<'a>, QuerierIter: IntoIterator<Item = Querier>,

Construct a database from an iterator of immutable queriers of desc files.

If there are collisions between queriers in name, the one with newer package version would override the older.

Source

pub fn from_newer_queriers_mut<QuerierIter>( queriers: QuerierIter, ) -> Result<Self, InsertNewerError<'a>>
where Querier: QueryMut<'a>, QuerierIter: IntoIterator<Item = Querier>,

Construct a database from an iterator of mutable queriers of desc files.

If there are collisions between queriers in name, the one with newer package version would override the older.

Source§

impl<'a, Querier> QueryDatabase<'a, Querier>

Source

pub fn names(&self) -> Names<'_, 'a, Querier>

Get an iterator over all package names.

Source§

impl<'a, Querier> QueryDatabase<'a, Querier>

Source

pub fn queriers(&self) -> Queriers<'_, 'a, Querier>

Get an iterator over all immutable queriers.

Source

pub fn queriers_mut(&mut self) -> QueriersMut<'_, 'a, Querier>

Get an iterator over all mutable queriers.

Source§

impl<'a, Querier> QueryDatabase<'a, Querier>

Source

pub fn len(&self) -> usize

The number of queriers within the database.

Source

pub fn is_empty(&self) -> bool

Whether the database is empty.

Source§

impl<Querier> QueryDatabase<'_, Querier>

Source

pub fn new() -> Self

Create an empty database.

Source

pub fn with_capacity(capacity: usize) -> Self

Create an empty database with at least the specified capacity.

Source§

impl<Querier> QueryDatabase<'_, Querier>

Source

pub fn alternative_providers<'a>( &'a self, target: DependencyName<'a>, ) -> AlternativeProviders<'a, 'a, Querier>

Get an iterator over all immutable queriers of packages which list a certain DependencyName in their provides array.

This method is prefixed with “alternative” because a package doesn’t usually list itself in its own provides, and consequently, would usually be excluded from this iterator. Beware that if it does list itself, its own name would be included.

Source

pub fn alternative_providers_mut<'a>( &'a mut self, target: DependencyName<'a>, ) -> AlternativeProvidersMut<'a, 'a, Querier>

Get an iterator over all mutable queriers of packages which list a certain DependencyName in their provides array.

This method is prefixed with “alternative” because a package doesn’t usually list itself in its own provides, and consequently, would usually be excluded from this iterator. Beware that if it does list itself, its own name would be included.

Trait Implementations§

Source§

impl<'a, Querier: Clone> Clone for QueryDatabase<'a, Querier>

Source§

fn clone(&self) -> QueryDatabase<'a, Querier>

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<'a, Querier: Debug> Debug for QueryDatabase<'a, Querier>

Source§

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

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

impl<Querier> Default for QueryDatabase<'_, Querier>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'a, Querier> IntoIterator for QueryDatabase<'a, Querier>

Source§

type IntoIter = OwnedEntries<'a, Querier>

Which kind of iterator are we turning this into?
Source§

type Item = Entry<'a, Querier>

The type of the elements being iterated over.
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'a, Querier> Freeze for QueryDatabase<'a, Querier>

§

impl<'a, Querier> RefUnwindSafe for QueryDatabase<'a, Querier>
where Querier: RefUnwindSafe,

§

impl<'a, Querier> Send for QueryDatabase<'a, Querier>
where Querier: Send,

§

impl<'a, Querier> Sync for QueryDatabase<'a, Querier>
where Querier: Sync,

§

impl<'a, Querier> Unpin for QueryDatabase<'a, Querier>
where Querier: Unpin,

§

impl<'a, Querier> UnwindSafe for QueryDatabase<'a, Querier>
where Querier: 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<Main> IntoAttached for Main

Source§

fn into_attached<Attachment>( self, attachment: Attachment, ) -> Attached<Self, Attachment>

Attach metadata to an object.
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> Is for T

Source§

type Type = T

Source§

fn into_val(self) -> <T as Is>::Type

Source§

fn into_ref(&self) -> &<T as Is>::Type

Source§

fn into_mut_ref(&mut self) -> &mut <T as Is>::Type

Source§

fn from_val(x: <T as Is>::Type) -> T

Source§

fn from_ref(x: &<T as Is>::Type) -> &T

Source§

fn from_mut_ref(x: &mut <T as Is>::Type) -> &mut T

Source§

impl<X> Pipe for X

Source§

fn pipe<Return, Function>(self, f: Function) -> Return
where Self: Sized, Function: FnOnce(Self) -> Return,

Apply f to self. Read more
Source§

fn pipe_ref<'a, Return, Function>(&'a self, f: Function) -> Return
where Function: FnOnce(&'a Self) -> Return,

Apply f to &self. Read more
Source§

fn pipe_mut<'a, Return, Function>(&'a mut self, f: Function) -> Return
where Function: FnOnce(&'a mut Self) -> Return,

Apply f to &mut self. Read more
Source§

fn pipe_as_ref<'a, Param, Return, Function>(&'a self, f: Function) -> Return
where Self: AsRef<Param>, Param: 'a + ?Sized, Function: FnOnce(&'a Param) -> Return,

Apply f to &self where f takes a single parameter of type Param and Self implements trait AsRef<Param>. Read more
Source§

fn pipe_as_mut<'a, Param, Return, Function>(&'a mut self, f: Function) -> Return
where Self: AsMut<Param>, Param: 'a + ?Sized, Function: FnOnce(&'a mut Param) -> Return,

Apply f to &mut self where f takes a single parameter of type Param and Self implements trait AsMut<Param>. Read more
Source§

fn pipe_deref<'a, Param, Return, Function>(&'a self, f: Function) -> Return
where Self: Deref<Target = Param>, Param: 'a + ?Sized, Function: FnOnce(&'a Param) -> Return,

Apply f to &self where f takes a single parameter of type Param and Self implements trait Deref<Target = Param>. Read more
Source§

fn pipe_deref_mut<'a, Param, Return, Function>( &'a mut self, f: Function, ) -> Return
where Self: DerefMut<Target = Param>, Param: 'a + ?Sized, Function: FnOnce(&'a mut Param) -> Return,

Apply f to &mut self where f takes a single parameter of type Param and Self implements trait DerefMut<Target = Param>. Read more
Source§

fn pipe_borrow<'a, Param, Return, Function>(&'a self, f: Function) -> Return
where Self: Borrow<Param>, Param: 'a + ?Sized, Function: FnOnce(&'a Param) -> Return,

Apply f to &self where f takes a single parameter of type Param and Self implements trait Borrow<Param>. Read more
Source§

fn pipe_borrow_mut<'a, Param, Return, Function>( &'a mut self, f: Function, ) -> Return
where Self: BorrowMut<Param>, Param: 'a + ?Sized, Function: FnOnce(&'a mut Param) -> Return,

Apply f to &mut self where f takes a single parameter of type Param and Self implements trait BorrowMut<Param>. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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, 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.