pub(crate) struct SetResolver<'a> {
manifest: &'a Manifest,
repo: Option<Repository>,
names: HashMap<Root, Tag>,
roots: HashMap<Either<Tag, SetMirror>, Root>,
tasks: JoinSet<Result<(Option<Box<dyn Transport + Send>>, <Vec<UnpackedRef<ObjectId, Root>> as IntoIterator>::IntoIter, Root, Tag, Url), Box<dyn Error + Send + Sync>>>,
atoms: HashMap<AtomId<Root>, HashMap<Version, ResolvedAtom<ObjectId, Root>>>,
sets: BTreeMap<GitDigest, SetDetails>,
transports: HashMap<Url, Box<dyn Transport + Send>>,
ekala: EkalaManager,
}Fields§
§manifest: &'a Manifest§repo: Option<Repository>§names: HashMap<Root, Tag>§roots: HashMap<Either<Tag, SetMirror>, Root>§tasks: JoinSet<Result<(Option<Box<dyn Transport + Send>>, <Vec<UnpackedRef<ObjectId, Root>> as IntoIterator>::IntoIter, Root, Tag, Url), Box<dyn Error + Send + Sync>>>§atoms: HashMap<AtomId<Root>, HashMap<Version, ResolvedAtom<ObjectId, Root>>>§sets: BTreeMap<GitDigest, SetDetails>§transports: HashMap<Url, Box<dyn Transport + Send>>§ekala: EkalaManagerImplementations§
Source§impl<'a> SetResolver<'a>
impl<'a> SetResolver<'a>
Sourcepub(crate) fn new(
repo: Option<&ThreadSafeRepository>,
manifest: &'a Manifest,
) -> Result<Self, AtomError>
pub(crate) fn new( repo: Option<&ThreadSafeRepository>, manifest: &'a Manifest, ) -> Result<Self, AtomError>
Creates a new SetResolver to validate the package sets in a manifest.
Sourcepub(crate) async fn get_and_check_sets(
self,
) -> Result<ResolvedSets, Box<dyn Error + Send + Sync>>
pub(crate) async fn get_and_check_sets( self, ) -> Result<ResolvedSets, Box<dyn Error + Send + Sync>>
Verifies the integrity of declared package sets and collects atom references.
This function consumes the resolver and performs several critical checks to ensure the consistency and integrity of the package sets defined in the manifest:
- Root Consistency: It ensures that every URL within a named mirror set points to the same underlying repository by verifying their advertised root hashes.
- Set Uniqueness: It guarantees that a given repository URL does not belong to more than one mirror set, preventing ambiguity.
- Version and Revision Coherency: It aggregates all atoms from each mirror, ensuring that no two mirrors advertise the same atom version with a different Git revision, which could indicate tampering or misconfiguration.
§Returns
A Result containing a ResolvedSets struct on success, which holds the aggregated
results of the validation process.
§Errors
Returns a BoxError if any of the following conditions are met:
- A repository is found in more than one mirror set.
- The mirrors for a given set do not all point to the same root hash.
- An atom is advertised with the same version but different revisions across mirrors.
Sourcefn process_mirror(
&mut self,
set_tag: &'a Tag,
mirror: &'a SetMirror,
) -> Result<(), Box<dyn Error + Send + Sync>>
fn process_mirror( &mut self, set_tag: &'a Tag, mirror: &'a SetMirror, ) -> Result<(), Box<dyn Error + Send + Sync>>
Processes a single mirror, either local or remote, and initiates consistency checks.
For local mirrors, it calculates the root hash directly. For remote mirrors, it spawns an asynchronous task to fetch repository data and perform checks.
fn update_sets(&mut self, name: &Tag, root: Root, set: SetMirror)
Sourcefn process_remote_mirror_result(
&mut self,
result: Result<(Option<Box<dyn Transport + Send>>, <Vec<UnpackedRef<ObjectId, Root>> as IntoIterator>::IntoIter, Root, Tag, Url), Box<dyn Error + Send + Sync>>,
) -> Result<(), Box<dyn Error + Send + Sync>>
fn process_remote_mirror_result( &mut self, result: Result<(Option<Box<dyn Transport + Send>>, <Vec<UnpackedRef<ObjectId, Root>> as IntoIterator>::IntoIter, Root, Tag, Url), Box<dyn Error + Send + Sync>>, ) -> Result<(), Box<dyn Error + Send + Sync>>
Handles the result of an asynchronous remote mirror check.
This function processes the data fetched from a remote mirror, performs consistency checks, and aggregates the results into the provided hashmaps.
Sourcefn check_and_insert_atom(
&mut self,
atom: UnpackedRef<ObjectId, Root>,
size: usize,
mirror_url: &Url,
) -> Result<(), Box<dyn Error + Send + Sync>>
fn check_and_insert_atom( &mut self, atom: UnpackedRef<ObjectId, Root>, size: usize, mirror_url: &Url, ) -> Result<(), Box<dyn Error + Send + Sync>>
Verifies the consistency of a single atom against the existing set of resolved atoms.
This check ensures that if an atom is advertised by multiple mirrors, it always has the same revision for the same version.
Sourcefn check_set_consistency(
&mut self,
set_tag: &Tag,
root: Root,
mirror: &SetMirror,
) -> Result<(), Box<dyn Error + Send + Sync>>
fn check_set_consistency( &mut self, set_tag: &Tag, root: Root, mirror: &SetMirror, ) -> Result<(), Box<dyn Error + Send + Sync>>
Ensures that a given package set is consistent across all its mirrors.
This check verifies two conditions:
- A repository root hash is not associated with more than one package set name.
- A package set name is not associated with more than one repository root hash.
Auto Trait Implementations§
impl<'a> !Freeze for SetResolver<'a>
impl<'a> !RefUnwindSafe for SetResolver<'a>
impl<'a> Send for SetResolver<'a>
impl<'a> !Sync for SetResolver<'a>
impl<'a> Unpin for SetResolver<'a>
impl<'a> !UnwindSafe for SetResolver<'a>
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);