Struct Abigen

Source
pub struct Abigen<'a> { /* private fields */ }
Expand description

Builder struct for generating type-safe bindings Rust code directly in your project from a contract’s ABI. This is equivalent to code generated by macro use_contract.

§Example

Running the code below will generate a file called erc721.rs containing the bindings inside, which exports an erc struct, along with all its events. Put into a build.rs file this will generate the bindings during cargo build.

    use anyhow::{Ok, Result};
    use substreams_ethereum::Abigen;

    fn main() -> Result<(), anyhow::Error> {
        Abigen::new("ERC721", "abi/erc721.json")?
            .generate()?
            .write_to_file("src/abi/erc721.rs")?;

        Ok(())
    }

Implementations§

Source§

impl<'a> Abigen<'a>

Source

pub fn new<S>(_contract_name: S, path: S) -> Result<Abigen<'a>, Error>
where S: AsRef<str>,

Creates a new builder for the given contract name and where the ABI JSON file can be found at path, which is relative to the your crate’s root directory (where Cargo.toml file is located).

Source

pub fn from_bytes<S>( _contract_name: S, abi_bytes: &'a [u8], ) -> Result<Abigen<'a>, Error>
where S: AsRef<str>,

Creates a new builder for the given contract name and where the ABI bytes can be found at ‘abi_bytes’.

Source

pub fn generate(&self) -> Result<GeneratedBindings, Error>

Trait Implementations§

Source§

impl<'a> Clone for Abigen<'a>

Source§

fn clone(&self) -> Abigen<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Abigen<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Abigen<'a>

§

impl<'a> RefUnwindSafe for Abigen<'a>

§

impl<'a> Send for Abigen<'a>

§

impl<'a> Sync for Abigen<'a>

§

impl<'a> Unpin for Abigen<'a>

§

impl<'a> UnwindSafe for Abigen<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V