Enum ethers_solc::artifacts::bytecode::BytecodeObject
source · [−]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
sourceimpl 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 Selfwhere
I: IntoIterator<Item = (S, T, Address)>,
S: AsRef<str>,
T: AsRef<str>,
pub fn link_all<I, S, T>(&mut self, libs: I) -> &mut Selfwhere
I: IntoIterator<Item = (S, T, Address)>,
S: AsRef<str>,
T: AsRef<str>,
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
sourceimpl AsRef<[u8]> for BytecodeObject
impl AsRef<[u8]> for BytecodeObject
sourceimpl Clone for BytecodeObject
impl Clone for BytecodeObject
sourcefn clone(&self) -> BytecodeObject
fn clone(&self) -> BytecodeObject
1.0.0 · sourceconst fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for BytecodeObject
impl Debug for BytecodeObject
sourceimpl Default for BytecodeObject
impl Default for BytecodeObject
sourceimpl<'de> Deserialize<'de> for BytecodeObject
impl<'de> Deserialize<'de> for BytecodeObject
sourcefn 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>,
sourceimpl From<BytecodeObject> for Bytecode
impl From<BytecodeObject> for Bytecode
sourcefn from(object: BytecodeObject) -> Bytecode
fn from(object: BytecodeObject) -> Bytecode
sourceimpl PartialEq<BytecodeObject> for BytecodeObject
impl PartialEq<BytecodeObject> for BytecodeObject
sourcefn eq(&self, other: &BytecodeObject) -> bool
fn eq(&self, other: &BytecodeObject) -> bool
sourceimpl Serialize for BytecodeObject
impl Serialize for BytecodeObject
impl Eq for BytecodeObject
impl StructuralEq 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
impl<U> AsSliceOf for Uwhere
U: AsRef<[u8]> + ?Sized,
impl<U> AsSliceOf for Uwhere
U: AsRef<[u8]> + ?Sized,
fn as_slice_of<T>(&self) -> Result<&[T], Error>where
T: FromByteSlice,
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToHex for Twhere
T: AsRef<[u8]>,
impl<T> ToHex for Twhere
T: AsRef<[u8]>,
sourcefn 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
) Read moresourcefn 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
) Read more