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§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§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> 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>,
encode
or other specialized functions 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>,
encode
or other specialized functions insteadself
into the result. Upper case
letters are used (e.g. F9B4CA
)