pub enum BytecodeObject {
Bytecode(Bytes),
Unlinked(String),
}
Expand description
Represents the bytecode of a contracts that might be not fully linked yet.
Variants§
Bytecode(Bytes)
Fully linked bytecode object.
Unlinked(String)
Bytecode as hex string that’s not fully linked yet and contains library placeholders.
Implementations§
source§impl BytecodeObject
impl BytecodeObject
sourcepub fn as_bytes(&self) -> Option<&Bytes>
pub fn as_bytes(&self) -> Option<&Bytes>
Returns a reference to the underlying Bytes
if the object is a valid bytecode.
sourcepub fn into_bytes(self) -> Option<Bytes>
pub fn into_bytes(self) -> Option<Bytes>
Returns the underlying Bytes
if the object is a valid bytecode.
sourcepub fn bytes_len(&self) -> usize
pub fn bytes_len(&self) -> usize
Returns the number of bytes of the fully linked bytecode.
Returns 0
if this object is unlinked.
sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns a reference to the underlying String
if the object is unlinked.
sourcepub fn into_unlinked(self) -> Option<String>
pub fn into_unlinked(self) -> Option<String>
Returns the unlinked String
if the object is unlinked.
sourcepub fn is_unlinked(&self) -> bool
pub fn is_unlinked(&self) -> bool
Whether this object is still unlinked.
sourcepub fn is_bytecode(&self) -> bool
pub fn is_bytecode(&self) -> bool
Whether this object a valid bytecode.
sourcepub fn is_non_empty_bytecode(&self) -> bool
pub fn is_non_empty_bytecode(&self) -> bool
Returns true
if the object is a valid bytecode and not empty.
Returns false
if the object is a valid but empty or unlinked bytecode.
sourcepub fn resolve(&mut self) -> Option<&Bytes>
pub fn resolve(&mut self) -> Option<&Bytes>
Tries to resolve the unlinked string object a valid bytecode object in place.
Returns the string if it is a valid
sourcepub fn link_fully_qualified(
&mut self,
name: &str,
addr: Address,
) -> &mut BytecodeObject
pub fn link_fully_qualified( &mut self, name: &str, addr: Address, ) -> &mut BytecodeObject
Links using the fully qualified name of a library.
The fully qualified library name is the path of its source file and the library name
separated by :
like file.sol:Math
This will replace all occurrences of the library placeholder with the given address.
See also: https://docs.soliditylang.org/en/develop/using-the-compiler.html#library-linking
sourcepub fn link(
&mut self,
file: &str,
library: &str,
addr: Address,
) -> &mut BytecodeObject
pub fn link( &mut self, file: &str, library: &str, addr: Address, ) -> &mut BytecodeObject
Links using the file
and library
names as fully qualified name <file>:<library>
.
See link_fully_qualified
.
sourcepub fn link_all<I, S, T>(&mut self, libs: I) -> &mut BytecodeObject
pub fn link_all<I, S, T>(&mut self, libs: I) -> &mut BytecodeObject
Links the bytecode object with all provided (file, lib, addr)
.
sourcepub fn contains_fully_qualified_placeholder(&self, name: &str) -> bool
pub fn contains_fully_qualified_placeholder(&self, name: &str) -> bool
Returns whether the bytecode contains a matching placeholder using the qualified name.
sourcepub fn contains_placeholder(&self, file: &str, library: &str) -> bool
pub fn contains_placeholder(&self, file: &str, library: &str) -> bool
Returns whether the bytecode contains a matching placeholder.
Trait Implementations§
source§impl AsRef<[u8]> for BytecodeObject
impl AsRef<[u8]> for BytecodeObject
source§impl Clone for BytecodeObject
impl Clone for BytecodeObject
source§fn clone(&self) -> BytecodeObject
fn clone(&self) -> BytecodeObject
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for BytecodeObject
impl Debug for BytecodeObject
source§impl Default for BytecodeObject
impl Default for BytecodeObject
source§fn default() -> BytecodeObject
fn default() -> BytecodeObject
source§impl<'de> Deserialize<'de> for BytecodeObject
impl<'de> Deserialize<'de> for BytecodeObject
source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<BytecodeObject, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<BytecodeObject, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl From<BytecodeObject> for Bytecode
impl From<BytecodeObject> for Bytecode
source§fn from(object: BytecodeObject) -> Bytecode
fn from(object: BytecodeObject) -> Bytecode
source§impl PartialEq for BytecodeObject
impl PartialEq for BytecodeObject
source§fn eq(&self, other: &BytecodeObject) -> bool
fn eq(&self, other: &BytecodeObject) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for BytecodeObject
impl Serialize for BytecodeObject
source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for BytecodeObject
impl StructuralPartialEq for BytecodeObject
Auto Trait Implementations§
impl !Freeze for BytecodeObject
impl RefUnwindSafe for BytecodeObject
impl Send for BytecodeObject
impl Sync for BytecodeObject
impl Unpin for BytecodeObject
impl UnwindSafe for BytecodeObject
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§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> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
source§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();
source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Returns self
with the
fg()
set to
Color::BrightBlack
.
§Example
println!("{}", value.bright_black());
source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Returns self
with the
fg()
set to
Color::BrightGreen
.
§Example
println!("{}", value.bright_green());
source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Returns self
with the
fg()
set to
Color::BrightYellow
.
§Example
println!("{}", value.bright_yellow());
source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Returns self
with the
fg()
set to
Color::BrightMagenta
.
§Example
println!("{}", value.bright_magenta());
source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Returns self
with the
fg()
set to
Color::BrightWhite
.
§Example
println!("{}", value.bright_white());
source§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();
source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Returns self
with the
bg()
set to
Color::BrightBlack
.
§Example
println!("{}", value.on_bright_black());
source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Returns self
with the
bg()
set to
Color::BrightGreen
.
§Example
println!("{}", value.on_bright_green());
source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Returns self
with the
bg()
set to
Color::BrightYellow
.
§Example
println!("{}", value.on_bright_yellow());
source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Returns self
with the
bg()
set to
Color::BrightBlue
.
§Example
println!("{}", value.on_bright_blue());
source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Returns self
with the
bg()
set to
Color::BrightMagenta
.
§Example
println!("{}", value.on_bright_magenta());
source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Returns self
with the
bg()
set to
Color::BrightCyan
.
§Example
println!("{}", value.on_bright_cyan());
source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Returns self
with the
bg()
set to
Color::BrightWhite
.
§Example
println!("{}", value.on_bright_white());
source§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();
source§fn underline(&self) -> Painted<&T>
fn underline(&self) -> Painted<&T>
Returns self
with the
attr()
set to
Attribute::Underline
.
§Example
println!("{}", value.underline());
source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Returns self
with the
attr()
set to
Attribute::RapidBlink
.
§Example
println!("{}", value.rapid_blink());
source§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();
source§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.source§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);
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> ToHex for T
impl<T> ToHex for T
source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
ToHexExt
insteadself
into the result.
Lower case letters are used (e.g. f9b4ca
).source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
ToHexExt
insteadself
into the result.
Upper case letters are used (e.g. F9B4CA
).source§impl<T> ToHexExt for T
impl<T> ToHexExt for T
source§fn encode_hex(&self) -> String
fn encode_hex(&self) -> String
self
into the result.
Lower case letters are used (e.g. f9b4ca
).source§fn encode_hex_upper(&self) -> String
fn encode_hex_upper(&self) -> String
self
into the result.
Upper case letters are used (e.g. F9B4CA
).source§fn encode_hex_with_prefix(&self) -> String
fn encode_hex_with_prefix(&self) -> String
self
into the result with prefix 0x
.
Lower case letters are used (e.g. 0xf9b4ca
).source§fn encode_hex_upper_with_prefix(&self) -> String
fn encode_hex_upper_with_prefix(&self) -> String
self
into the result with prefix 0X
.
Upper case letters are used (e.g. 0xF9B4CA
).