pub struct Linker<'a> {
pub root: PathBuf,
pub contracts: ArtifactContracts<CompactContractBytecodeCow<'a>>,
}
Fields§
§root: PathBuf
Root of the project, used to determine whether artifact/library path can be stripped.
contracts: ArtifactContracts<CompactContractBytecodeCow<'a>>
Compilation artifacts.
Implementations§
Source§impl<'a> Linker<'a>
impl<'a> Linker<'a>
pub fn new( root: impl Into<PathBuf>, contracts: ArtifactContracts<CompactContractBytecodeCow<'a>>, ) -> Self
Sourcepub(crate) fn convert_artifact_id_to_lib_path(
&self,
id: &ArtifactId,
) -> (PathBuf, String)
pub(crate) fn convert_artifact_id_to_lib_path( &self, id: &ArtifactId, ) -> (PathBuf, String)
Helper method to convert [ArtifactId] to the format in which libraries are stored in [Libraries] object.
Strips project root path from source file path.
Sourcepub(crate) fn find_artifact_id_by_library_path(
&'a self,
file: &str,
name: &str,
version: Option<&Version>,
) -> Option<&'a ArtifactId>
pub(crate) fn find_artifact_id_by_library_path( &'a self, file: &str, name: &str, version: Option<&Version>, ) -> Option<&'a ArtifactId>
Finds an [ArtifactId] object in the given [ArtifactContracts] keys which corresponds to the library path in the form of “./path/to/Lib.sol:Lib”
Optionally accepts solc version, and if present, only compares artifacts with given version.
Sourcepub(crate) fn collect_dependencies(
&'a self,
target: &'a ArtifactId,
deps: &mut BTreeSet<&'a ArtifactId>,
) -> Result<(), LinkerError>
pub(crate) fn collect_dependencies( &'a self, target: &'a ArtifactId, deps: &mut BTreeSet<&'a ArtifactId>, ) -> Result<(), LinkerError>
Performs DFS on the graph of link references, and populates deps
with all found libraries.
Sourcepub fn link_with_nonce_or_address(
&'a self,
libraries: Libraries,
sender: Address,
nonce: u64,
targets: impl IntoIterator<Item = &'a ArtifactId>,
) -> Result<LinkOutput, LinkerError>
pub fn link_with_nonce_or_address( &'a self, libraries: Libraries, sender: Address, nonce: u64, targets: impl IntoIterator<Item = &'a ArtifactId>, ) -> Result<LinkOutput, LinkerError>
Links given artifact with either given library addresses or address computed from sender and nonce.
Each key in libraries
should either be a global path or relative to project root. All
remappings should be resolved.
When calling for target
being an external library itself, you should check that target
does not appear in libs_to_deploy
to avoid deploying it twice. It may happen in cases
when there is a dependency cycle including target
.
pub fn link_with_create2( &'a self, libraries: Libraries, sender: Address, salt: B256, target: &'a ArtifactId, ) -> Result<LinkOutput, LinkerError>
Sourcepub fn link(
&self,
target: &ArtifactId,
libraries: &Libraries,
) -> Result<CompactContractBytecodeCow<'a>, LinkerError>
pub fn link( &self, target: &ArtifactId, libraries: &Libraries, ) -> Result<CompactContractBytecodeCow<'a>, LinkerError>
Links given artifact with given libraries.
pub fn get_linked_artifacts( &self, libraries: &Libraries, ) -> Result<ArtifactContracts, LinkerError>
pub fn get_linked_artifacts_cow( &self, libraries: &Libraries, ) -> Result<ArtifactContracts<CompactContractBytecodeCow<'a>>, LinkerError>
Auto Trait Implementations§
impl<'a> Freeze for Linker<'a>
impl<'a> RefUnwindSafe for Linker<'a>
impl<'a> Send for Linker<'a>
impl<'a> Sync for Linker<'a>
impl<'a> Unpin for Linker<'a>
impl<'a> UnwindSafe for Linker<'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, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for 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 more§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);
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 48 bytes