pub struct ManifestWriter {
path: PathBuf,
doc: TypedDocument<Manifest>,
lock: Lockfile,
resolved: ResolvedSets,
}Expand description
A writer for atom.toml manifests that ensures the atom.lock file is kept in sync.
§Example
use std::path::Path;
use atom::id::Tag;
use atom::manifest::deps::ManifestWriter;
use atom::uri::Uri;
async {
let mut writer = ManifestWriter::new(None, Path::new("/path/to/atom.toml"))
.await
.unwrap();
let uri = "my-atom@^1.0.0".parse::<Uri>().unwrap();
let key = "my-atom".parse::<Tag>().unwrap();
writer.add_uri(uri, Some(key)).unwrap();
writer.write_atomic().unwrap();
};Fields§
§path: PathBuf§doc: TypedDocument<Manifest>§lock: Lockfile§resolved: ResolvedSetsImplementations§
Source§impl ManifestWriter
impl ManifestWriter
const ATOM_BUG: &str = "bug, `AtomId` construction is infallible when derived directly from a \ root and doesn't need to be calculated"
const RESOLUTION_ERR_MSG: &str = "unlocked dependency could not be resolved remotely"
const UPDATE_DEPENDENCY: &str = "updating out of date dependency in accordance with spec"
Sourcepub async fn new(
repo: Option<&ThreadSafeRepository>,
path: &Path,
) -> Result<Self, AtomError>
pub async fn new( repo: Option<&ThreadSafeRepository>, path: &Path, ) -> Result<Self, AtomError>
Constructs a new ManifestWriter, ensuring that the manifest and lock file constraints
are respected.
Sourceasync fn reconcile(&mut self, manifest: Manifest) -> Result<(), DocError>
async fn reconcile(&mut self, manifest: Manifest) -> Result<(), DocError>
Runs the sanitization process, and then the synchronization process to ensure a fully
consistent manifest and lock. This function is called in the ManifestWriter constructor
to ensure that we are never operating on a stale manifest.
fn set_sets(&mut self)
Sourcefn sanitize(&mut self, manifest: &Manifest)
fn sanitize(&mut self, manifest: &Manifest)
Removes any dependencies from the lockfile that are no longer present in the manifest, ensuring the lockfile only contains entries that are still relevant, then calls into synchronization logic to ensure consistency.
fn insert_or_update_and_log( &mut self, key: Either<AtomId<Root>, Name>, dep: &Dep, )
fn lock_atom( &mut self, req: VersionReq, id: AtomId<Root>, set_tag: Tag, ) -> Result<Dep, Error>
fn synchronize_atom( &mut self, req: VersionReq, id: AtomId<Root>, set_tag: Tag, ) -> Result<(), Error>
Sourcepub(crate) async fn synchronize(
&mut self,
manifest: Manifest,
) -> Result<(), DocError>
pub(crate) async fn synchronize( &mut self, manifest: Manifest, ) -> Result<(), DocError>
Updates the lockfile to match the dependencies specified in the manifest. It resolves any new dependencies, updates existing ones if their version requirements have changed, and ensures the lockfile is fully consistent.
async fn resolve_nix( &self, dep: NixFetch, key: Option<&Name>, ) -> Result<(Name, Dep), DocError>
fn resolve_from_uri( &self, uri: &Uri, root: &Root, ) -> Result<(AtomReq, AtomDep), Error>
fn resolve_from_local( &self, uri: &Uri, repo: &Repository, ) -> Result<(AtomReq, AtomDep), Error>
fn resolve_uri( &mut self, uri: &Uri, mirror: &SetMirror, ) -> Result<(AtomReq, AtomDep), Error>
fn get_set_tag( &self, lock_entry: &AtomDep, uri: &Uri, set_tag_from_user: Option<Tag>, ) -> Tag
fn update_lock_set(&mut self, set: GitDigest, mirror: SetMirror, tag: Tag)
Sourcepub fn add_uri(&mut self, uri: Uri, set_tag: Option<Tag>) -> Result<(), Error>
pub fn add_uri(&mut self, uri: Uri, set_tag: Option<Tag>) -> Result<(), Error>
Adds a user-requested atom URI to the manifest and lock files, ensuring they remain in sync.
Sourcepub async fn add_url(
&mut self,
url: AliasedUrl,
key: Option<Name>,
git: Option<GitSpec>,
tar: Option<bool>,
build: bool,
unpack: Option<bool>,
) -> Result<(), DocError>
pub async fn add_url( &mut self, url: AliasedUrl, key: Option<Name>, git: Option<GitSpec>, tar: Option<bool>, build: bool, unpack: Option<bool>, ) -> Result<(), DocError>
Adds a user-requested pin URL to the manifest and lock files, ensuring they remain in sync.
Sourcepub fn write_atomic(&mut self) -> Result<(), DocError>
pub fn write_atomic(&mut self) -> Result<(), DocError>
Atomically writes the changes to the manifest and lock files on disk. This method should be called last, after all changes have been processed.
fn resolved(&self) -> &ResolvedSets
Auto Trait Implementations§
impl !Freeze for ManifestWriter
impl !RefUnwindSafe for ManifestWriter
impl Send for ManifestWriter
impl !Sync for ManifestWriter
impl Unpin for ManifestWriter
impl !UnwindSafe for ManifestWriter
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);