Enum ethers_solc::artifacts::bytecode::BytecodeObject
source · 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 into_bytes(self) -> Option<Bytes>
pub fn into_bytes(self) -> Option<Bytes>
Returns the underlying Bytes
if the object is a valid bytecode, and not empty
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, and not
empty
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 or empty
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 the object is a valid but empty bytecode or unlinked.
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: impl AsRef<str>,
addr: Address
) -> &mut Self
pub fn link_fully_qualified( &mut self, name: impl AsRef<str>, addr: Address ) -> &mut Self
Link 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: impl AsRef<str>,
library: impl AsRef<str>,
addr: Address
) -> &mut Self
pub fn link( &mut self, file: impl AsRef<str>, library: impl AsRef<str>, addr: Address ) -> &mut Self
Link using the file
and library
names as fully qualified name <file>:<library>
See BytecodeObject::link_fully_qualified
sourcepub fn link_all<I, S, T>(&mut self, libs: I) -> &mut Self
pub fn link_all<I, S, T>(&mut self, libs: I) -> &mut Self
Links the bytecode object with all provided (file, lib, addr)
sourcepub fn contains_fully_qualified_placeholder(
&self,
name: impl AsRef<str>
) -> bool
pub fn contains_fully_qualified_placeholder( &self, name: impl AsRef<str> ) -> bool
Whether the bytecode contains a matching placeholder using the qualified name
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§impl<'de> Deserialize<'de> for BytecodeObject
impl<'de> Deserialize<'de> for BytecodeObject
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::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
impl Eq for BytecodeObject
impl StructuralPartialEq for BytecodeObject
Auto Trait Implementations§
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, U> AsByteSlice<T> for U
impl<T, U> AsByteSlice<T> for U
fn as_byte_slice(&self) -> &[u8] ⓘ
source§impl<U> AsSliceOf for U
impl<U> AsSliceOf for U
fn as_slice_of<T>(&self) -> Result<&[T], Error>where
T: FromByteSlice,
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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> 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>,
self
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>,
self
into the result. Upper case
letters are used (e.g. F9B4CA
)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
).