Type Alias FeeHistoryCache

Source
pub type FeeHistoryCache = Arc<Mutex<BTreeMap<u64, FeeHistoryCacheItem>>>;

Aliased Type§

struct FeeHistoryCache { /* private fields */ }

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 8 bytes

Implementations

Source§

impl<T> Arc<T>
where T: ?Sized,

1.17.0 · Source

pub unsafe fn from_raw(ptr: *const T) -> Arc<T>

Constructs an Arc<T> from a raw pointer.

The raw pointer must have been previously returned by a call to Arc<U>::into_raw with the following requirements:

  • If U is sized, it must have the same size and alignment as T. This is trivially true if U is T.
  • If U is unsized, its data pointer must have the same size and alignment as T. This is trivially true if Arc<U> was constructed through Arc<T> and then converted to Arc<U> through an unsized coercion.

Note that if U or U’s data pointer is not T but has the same size and alignment, this is basically like transmuting references of different types. See mem::transmute for more information on what restrictions apply in this case.

The raw pointer must point to a block of memory allocated by the global allocator.

The user of from_raw has to make sure a specific value of T is only dropped once.

This function is unsafe because improper use may lead to memory unsafety, even if the returned Arc<T> is never accessed.

§Examples
use std::sync::Arc;

let x = Arc::new("hello".to_owned());
let x_ptr = Arc::into_raw(x);

unsafe {
    // Convert back to an `Arc` to prevent leak.
    let x = Arc::from_raw(x_ptr);
    assert_eq!(&*x, "hello");

    // Further calls to `Arc::from_raw(x_ptr)` would be memory-unsafe.
}

// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!

Convert a slice back into its original array:

use std::sync::Arc;

let x: Arc<[u32]> = Arc::new([1, 2, 3]);
let x_ptr: *const [u32] = Arc::into_raw(x);

unsafe {
    let x: Arc<[u32; 3]> = Arc::from_raw(x_ptr.cast::<[u32; 3]>());
    assert_eq!(&*x, &[1, 2, 3]);
}
1.51.0 · Source

pub unsafe fn increment_strong_count(ptr: *const T)

Increments the strong reference count on the Arc<T> associated with the provided pointer by one.

§Safety

The pointer must have been obtained through Arc::into_raw and must satisfy the same layout requirements specified in Arc::from_raw_in. The associated Arc instance must be valid (i.e. the strong count must be at least 1) for the duration of this method, and ptr must point to a block of memory allocated by the global allocator.

§Examples
use std::sync::Arc;

let five = Arc::new(5);

unsafe {
    let ptr = Arc::into_raw(five);
    Arc::increment_strong_count(ptr);

    // This assertion is deterministic because we haven't shared
    // the `Arc` between threads.
    let five = Arc::from_raw(ptr);
    assert_eq!(2, Arc::strong_count(&five));
}
1.51.0 · Source

pub unsafe fn decrement_strong_count(ptr: *const T)

Decrements the strong reference count on the Arc<T> associated with the provided pointer by one.

§Safety

The pointer must have been obtained through Arc::into_raw and must satisfy the same layout requirements specified in Arc::from_raw_in. The associated Arc instance must be valid (i.e. the strong count must be at least 1) when invoking this method, and ptr must point to a block of memory allocated by the global allocator. This method can be used to release the final Arc and backing storage, but should not be called after the final Arc has been released.

§Examples
use std::sync::Arc;

let five = Arc::new(5);

unsafe {
    let ptr = Arc::into_raw(five);
    Arc::increment_strong_count(ptr);

    // Those assertions are deterministic because we haven't shared
    // the `Arc` between threads.
    let five = Arc::from_raw(ptr);
    assert_eq!(2, Arc::strong_count(&five));
    Arc::decrement_strong_count(ptr);
    assert_eq!(1, Arc::strong_count(&five));
}
Source§

impl<T> Arc<T>

1.0.0 · Source

pub fn new(data: T) -> Arc<T>

Constructs a new Arc<T>.

§Examples
use std::sync::Arc;

let five = Arc::new(5);
1.60.0 · Source

pub fn new_cyclic<F>(data_fn: F) -> Arc<T>
where F: FnOnce(&Weak<T>) -> T,

Constructs a new Arc<T> while giving you a Weak<T> to the allocation, to allow you to construct a T which holds a weak pointer to itself.

Generally, a structure circularly referencing itself, either directly or indirectly, should not hold a strong reference to itself to prevent a memory leak. Using this function, you get access to the weak pointer during the initialization of T, before the Arc<T> is created, such that you can clone and store it inside the T.

new_cyclic first allocates the managed allocation for the Arc<T>, then calls your closure, giving it a Weak<T> to this allocation, and only afterwards completes the construction of the Arc<T> by placing the T returned from your closure into the allocation.

Since the new Arc<T> is not fully-constructed until Arc<T>::new_cyclic returns, calling upgrade on the weak reference inside your closure will fail and result in a None value.

§Panics

If data_fn panics, the panic is propagated to the caller, and the temporary Weak<T> is dropped normally.

§Example
use std::sync::{Arc, Weak};

struct Gadget {
    me: Weak<Gadget>,
}

impl Gadget {
    /// Constructs a reference counted Gadget.
    fn new() -> Arc<Self> {
        // `me` is a `Weak<Gadget>` pointing at the new allocation of the
        // `Arc` we're constructing.
        Arc::new_cyclic(|me| {
            // Create the actual struct here.
            Gadget { me: me.clone() }
        })
    }

    /// Returns a reference counted pointer to Self.
    fn me(&self) -> Arc<Self> {
        self.me.upgrade().unwrap()
    }
}
1.82.0 · Source

pub fn new_uninit() -> Arc<MaybeUninit<T>>

Constructs a new Arc with uninitialized contents.

§Examples
#![feature(get_mut_unchecked)]

use std::sync::Arc;

let mut five = Arc::<u32>::new_uninit();

// Deferred initialization:
Arc::get_mut(&mut five).unwrap().write(5);

let five = unsafe { five.assume_init() };

assert_eq!(*five, 5)
Source

pub fn new_zeroed() -> Arc<MaybeUninit<T>>

🔬This is a nightly-only experimental API. (new_zeroed_alloc)

Constructs a new Arc with uninitialized contents, with the memory being filled with 0 bytes.

See MaybeUninit::zeroed for examples of correct and incorrect usage of this method.

§Examples
#![feature(new_zeroed_alloc)]

use std::sync::Arc;

let zero = Arc::<u32>::new_zeroed();
let zero = unsafe { zero.assume_init() };

assert_eq!(*zero, 0)
1.33.0 · Source

pub fn pin(data: T) -> Pin<Arc<T>>

Constructs a new Pin<Arc<T>>. If T does not implement Unpin, then data will be pinned in memory and unable to be moved.

Source

pub fn try_pin(data: T) -> Result<Pin<Arc<T>>, AllocError>

🔬This is a nightly-only experimental API. (allocator_api)

Constructs a new Pin<Arc<T>>, return an error if allocation fails.

Source

pub fn try_new(data: T) -> Result<Arc<T>, AllocError>

🔬This is a nightly-only experimental API. (allocator_api)

Constructs a new Arc<T>, returning an error if allocation fails.

§Examples
#![feature(allocator_api)]
use std::sync::Arc;

let five = Arc::try_new(5)?;
Source

pub fn try_new_uninit() -> Result<Arc<MaybeUninit<T>>, AllocError>

🔬This is a nightly-only experimental API. (allocator_api)

Constructs a new Arc with uninitialized contents, returning an error if allocation fails.

§Examples
#![feature(allocator_api)]
#![feature(get_mut_unchecked)]

use std::sync::Arc;

let mut five = Arc::<u32>::try_new_uninit()?;

// Deferred initialization:
Arc::get_mut(&mut five).unwrap().write(5);

let five = unsafe { five.assume_init() };

assert_eq!(*five, 5);
Source

pub fn try_new_zeroed() -> Result<Arc<MaybeUninit<T>>, AllocError>

🔬This is a nightly-only experimental API. (allocator_api)

Constructs a new Arc with uninitialized contents, with the memory being filled with 0 bytes, returning an error if allocation fails.

See MaybeUninit::zeroed for examples of correct and incorrect usage of this method.

§Examples
#![feature( allocator_api)]

use std::sync::Arc;

let zero = Arc::<u32>::try_new_zeroed()?;
let zero = unsafe { zero.assume_init() };

assert_eq!(*zero, 0);
Source§

impl<T, A> Arc<T, A>
where A: Allocator, T: ?Sized,

Source

pub fn allocator(this: &Arc<T, A>) -> &A

🔬This is a nightly-only experimental API. (allocator_api)

Returns a reference to the underlying allocator.

Note: this is an associated function, which means that you have to call it as Arc::allocator(&a) instead of a.allocator(). This is so that there is no conflict with a method on the inner type.

1.17.0 · Source

pub fn into_raw(this: Arc<T, A>) -> *const T

Consumes the Arc, returning the wrapped pointer.

To avoid a memory leak the pointer must be converted back to an Arc using Arc::from_raw.

§Examples
use std::sync::Arc;

let x = Arc::new("hello".to_owned());
let x_ptr = Arc::into_raw(x);
assert_eq!(unsafe { &*x_ptr }, "hello");
Source

pub fn into_raw_with_allocator(this: Arc<T, A>) -> (*const T, A)

🔬This is a nightly-only experimental API. (allocator_api)

Consumes the Arc, returning the wrapped pointer and allocator.

To avoid a memory leak the pointer must be converted back to an Arc using Arc::from_raw_in.

§Examples
#![feature(allocator_api)]
use std::sync::Arc;
use std::alloc::System;

let x = Arc::new_in("hello".to_owned(), System);
let (ptr, alloc) = Arc::into_raw_with_allocator(x);
assert_eq!(unsafe { &*ptr }, "hello");
let x = unsafe { Arc::from_raw_in(ptr, alloc) };
assert_eq!(&*x, "hello");
1.45.0 · Source

pub fn as_ptr(this: &Arc<T, A>) -> *const T

Provides a raw pointer to the data.

The counts are not affected in any way and the Arc is not consumed. The pointer is valid for as long as there are strong counts in the Arc.

§Examples
use std::sync::Arc;

let x = Arc::new("hello".to_owned());
let y = Arc::clone(&x);
let x_ptr = Arc::as_ptr(&x);
assert_eq!(x_ptr, Arc::as_ptr(&y));
assert_eq!(unsafe { &*x_ptr }, "hello");
Source

pub unsafe fn from_raw_in(ptr: *const T, alloc: A) -> Arc<T, A>

🔬This is a nightly-only experimental API. (allocator_api)

Constructs an Arc<T, A> from a raw pointer.

The raw pointer must have been previously returned by a call to Arc<U, A>::into_raw with the following requirements:

  • If U is sized, it must have the same size and alignment as T. This is trivially true if U is T.
  • If U is unsized, its data pointer must have the same size and alignment as T. This is trivially true if Arc<U> was constructed through Arc<T> and then converted to Arc<U> through an unsized coercion.

Note that if U or U’s data pointer is not T but has the same size and alignment, this is basically like transmuting references of different types. See mem::transmute for more information on what restrictions apply in this case.

The raw pointer must point to a block of memory allocated by alloc

The user of from_raw has to make sure a specific value of T is only dropped once.

This function is unsafe because improper use may lead to memory unsafety, even if the returned Arc<T> is never accessed.

§Examples
#![feature(allocator_api)]

use std::sync::Arc;
use std::alloc::System;

let x = Arc::new_in("hello".to_owned(), System);
let x_ptr = Arc::into_raw(x);

unsafe {
    // Convert back to an `Arc` to prevent leak.
    let x = Arc::from_raw_in(x_ptr, System);
    assert_eq!(&*x, "hello");

    // Further calls to `Arc::from_raw(x_ptr)` would be memory-unsafe.
}

// The memory was freed when `x` went out of scope above, so `x_ptr` is now dangling!

Convert a slice back into its original array:

#![feature(allocator_api)]

use std::sync::Arc;
use std::alloc::System;

let x: Arc<[u32], _> = Arc::new_in([1, 2, 3], System);
let x_ptr: *const [u32] = Arc::into_raw(x);

unsafe {
    let x: Arc<[u32; 3], _> = Arc::from_raw_in(x_ptr.cast::<[u32; 3]>(), System);
    assert_eq!(&*x, &[1, 2, 3]);
}
1.4.0 · Source

pub fn downgrade(this: &Arc<T, A>) -> Weak<T, A>
where A: Clone,

Creates a new Weak pointer to this allocation.

§Examples
use std::sync::Arc;

let five = Arc::new(5);

let weak_five = Arc::downgrade(&five);
1.15.0 · Source

pub fn weak_count(this: &Arc<T, A>) -> usize

Gets the number of Weak pointers to this allocation.

§Safety

This method by itself is safe, but using it correctly requires extra care. Another thread can change the weak count at any time, including potentially between calling this method and acting on the result.

§Examples
use std::sync::Arc;

let five = Arc::new(5);
let _weak_five = Arc::downgrade(&five);

// This assertion is deterministic because we haven't shared
// the `Arc` or `Weak` between threads.
assert_eq!(1, Arc::weak_count(&five));
1.15.0 · Source

pub fn strong_count(this: &Arc<T, A>) -> usize

Gets the number of strong (Arc) pointers to this allocation.

§Safety

This method by itself is safe, but using it correctly requires extra care. Another thread can change the strong count at any time, including potentially between calling this method and acting on the result.

§Examples
use std::sync::Arc;

let five = Arc::new(5);
let _also_five = Arc::clone(&five);

// This assertion is deterministic because we haven't shared
// the `Arc` between threads.
assert_eq!(2, Arc::strong_count(&five));
Source

pub unsafe fn increment_strong_count_in(ptr: *const T, alloc: A)
where A: Clone,

🔬This is a nightly-only experimental API. (allocator_api)

Increments the strong reference count on the Arc<T> associated with the provided pointer by one.

§Safety

The pointer must have been obtained through Arc::into_raw and must satisfy the same layout requirements specified in Arc::from_raw_in. The associated Arc instance must be valid (i.e. the strong count must be at least 1) for the duration of this method, and ptr must point to a block of memory allocated by alloc.

§Examples
#![feature(allocator_api)]

use std::sync::Arc;
use std::alloc::System;

let five = Arc::new_in(5, System);

unsafe {
    let ptr = Arc::into_raw(five);
    Arc::increment_strong_count_in(ptr, System);

    // This assertion is deterministic because we haven't shared
    // the `Arc` between threads.
    let five = Arc::from_raw_in(ptr, System);
    assert_eq!(2, Arc::strong_count(&five));
}
Source

pub unsafe fn decrement_strong_count_in(ptr: *const T, alloc: A)

🔬This is a nightly-only experimental API. (allocator_api)

Decrements the strong reference count on the Arc<T> associated with the provided pointer by one.

§Safety

The pointer must have been obtained through Arc::into_raw and must satisfy the same layout requirements specified in Arc::from_raw_in. The associated Arc instance must be valid (i.e. the strong count must be at least 1) when invoking this method, and ptr must point to a block of memory allocated by alloc. This method can be used to release the final Arc and backing storage, but should not be called after the final Arc has been released.

§Examples
#![feature(allocator_api)]

use std::sync::Arc;
use std::alloc::System;

let five = Arc::new_in(5, System);

unsafe {
    let ptr = Arc::into_raw(five);
    Arc::increment_strong_count_in(ptr, System);

    // Those assertions are deterministic because we haven't shared
    // the `Arc` between threads.
    let five = Arc::from_raw_in(ptr, System);
    assert_eq!(2, Arc::strong_count(&five));
    Arc::decrement_strong_count_in(ptr, System);
    assert_eq!(1, Arc::strong_count(&five));
}
1.17.0 · Source

pub fn ptr_eq(this: &Arc<T, A>, other: &Arc<T, A>) -> bool

Returns true if the two Arcs point to the same allocation in a vein similar to ptr::eq. This function ignores the metadata of dyn Trait pointers.

§Examples
use std::sync::Arc;

let five = Arc::new(5);
let same_five = Arc::clone(&five);
let other_five = Arc::new(5);

assert!(Arc::ptr_eq(&five, &same_five));
assert!(!Arc::ptr_eq(&five, &other_five));
Source§

impl<T, A> Arc<T, A>
where T: CloneToUninit + ?Sized, A: Allocator + Clone,

1.4.0 · Source

pub fn make_mut(this: &mut Arc<T, A>) -> &mut T

Makes a mutable reference into the given Arc.

If there are other Arc pointers to the same allocation, then make_mut will clone the inner value to a new allocation to ensure unique ownership. This is also referred to as clone-on-write.

However, if there are no other Arc pointers to this allocation, but some Weak pointers, then the Weak pointers will be dissociated and the inner value will not be cloned.

See also get_mut, which will fail rather than cloning the inner value or dissociating Weak pointers.

§Examples
use std::sync::Arc;

let mut data = Arc::new(5);

*Arc::make_mut(&mut data) += 1;         // Won't clone anything
let mut other_data = Arc::clone(&data); // Won't clone inner data
*Arc::make_mut(&mut data) += 1;         // Clones inner data
*Arc::make_mut(&mut data) += 1;         // Won't clone anything
*Arc::make_mut(&mut other_data) *= 2;   // Won't clone anything

// Now `data` and `other_data` point to different allocations.
assert_eq!(*data, 8);
assert_eq!(*other_data, 12);

Weak pointers will be dissociated:

use std::sync::Arc;

let mut data = Arc::new(75);
let weak = Arc::downgrade(&data);

assert!(75 == *data);
assert!(75 == *weak.upgrade().unwrap());

*Arc::make_mut(&mut data) += 1;

assert!(76 == *data);
assert!(weak.upgrade().is_none());
Source§

impl<T, A> Arc<T, A>
where T: Clone, A: Allocator,

1.76.0 · Source

pub fn unwrap_or_clone(this: Arc<T, A>) -> T

If we have the only reference to T then unwrap it. Otherwise, clone T and return the clone.

Assuming arc_t is of type Arc<T>, this function is functionally equivalent to (*arc_t).clone(), but will avoid cloning the inner value where possible.

§Examples
let inner = String::from("test");
let ptr = inner.as_ptr();

let arc = Arc::new(inner);
let inner = Arc::unwrap_or_clone(arc);
// The inner value was not cloned
assert!(ptr::eq(ptr, inner.as_ptr()));

let arc = Arc::new(inner);
let arc2 = arc.clone();
let inner = Arc::unwrap_or_clone(arc);
// Because there were 2 references, we had to clone the inner value.
assert!(!ptr::eq(ptr, inner.as_ptr()));
// `arc2` is the last reference, so when we unwrap it we get back
// the original `String`.
let inner = Arc::unwrap_or_clone(arc2);
assert!(ptr::eq(ptr, inner.as_ptr()));
Source§

impl<T, A> Arc<T, A>
where A: Allocator, T: ?Sized,

1.4.0 · Source

pub fn get_mut(this: &mut Arc<T, A>) -> Option<&mut T>

Returns a mutable reference into the given Arc, if there are no other Arc or Weak pointers to the same allocation.

Returns None otherwise, because it is not safe to mutate a shared value.

See also make_mut, which will clone the inner value when there are other Arc pointers.

§Examples
use std::sync::Arc;

let mut x = Arc::new(3);
*Arc::get_mut(&mut x).unwrap() = 4;
assert_eq!(*x, 4);

let _y = Arc::clone(&x);
assert!(Arc::get_mut(&mut x).is_none());
Source

pub unsafe fn get_mut_unchecked(this: &mut Arc<T, A>) -> &mut T

🔬This is a nightly-only experimental API. (get_mut_unchecked)

Returns a mutable reference into the given Arc, without any check.

See also get_mut, which is safe and does appropriate checks.

§Safety

If any other Arc or Weak pointers to the same allocation exist, then they must not be dereferenced or have active borrows for the duration of the returned borrow, and their inner type must be exactly the same as the inner type of this Rc (including lifetimes). This is trivially the case if no such pointers exist, for example immediately after Arc::new.

§Examples
#![feature(get_mut_unchecked)]

use std::sync::Arc;

let mut x = Arc::new(String::new());
unsafe {
    Arc::get_mut_unchecked(&mut x).push_str("foo")
}
assert_eq!(*x, "foo");

Other Arc pointers to the same allocation must be to the same type.

#![feature(get_mut_unchecked)]

use std::sync::Arc;

let x: Arc<str> = Arc::from("Hello, world!");
let mut y: Arc<[u8]> = x.clone().into();
unsafe {
    // this is Undefined Behavior, because x's inner type is str, not [u8]
    Arc::get_mut_unchecked(&mut y).fill(0xff); // 0xff is invalid in UTF-8
}
println!("{}", &*x); // Invalid UTF-8 in a str

Other Arc pointers to the same allocation must be to the exact same type, including lifetimes.

#![feature(get_mut_unchecked)]

use std::sync::Arc;

let x: Arc<&str> = Arc::new("Hello, world!");
{
    let s = String::from("Oh, no!");
    let mut y: Arc<&str> = x.clone();
    unsafe {
        // this is Undefined Behavior, because x's inner type
        // is &'long str, not &'short str
        *Arc::get_mut_unchecked(&mut y) = &s;
    }
}
println!("{}", &*x); // Use-after-free
Source§

impl<T, A> Arc<T, A>
where A: Allocator,

Source

pub fn new_in(data: T, alloc: A) -> Arc<T, A>

🔬This is a nightly-only experimental API. (allocator_api)

Constructs a new Arc<T> in the provided allocator.

§Examples
#![feature(allocator_api)]

use std::sync::Arc;
use std::alloc::System;

let five = Arc::new_in(5, System);
Source

pub fn new_uninit_in(alloc: A) -> Arc<MaybeUninit<T>, A>

🔬This is a nightly-only experimental API. (allocator_api)

Constructs a new Arc with uninitialized contents in the provided allocator.

§Examples
#![feature(get_mut_unchecked)]
#![feature(allocator_api)]

use std::sync::Arc;
use std::alloc::System;

let mut five = Arc::<u32, _>::new_uninit_in(System);

let five = unsafe {
    // Deferred initialization:
    Arc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);

    five.assume_init()
};

assert_eq!(*five, 5)
Source

pub fn new_zeroed_in(alloc: A) -> Arc<MaybeUninit<T>, A>

🔬This is a nightly-only experimental API. (allocator_api)

Constructs a new Arc with uninitialized contents, with the memory being filled with 0 bytes, in the provided allocator.

See MaybeUninit::zeroed for examples of correct and incorrect usage of this method.

§Examples
#![feature(allocator_api)]

use std::sync::Arc;
use std::alloc::System;

let zero = Arc::<u32, _>::new_zeroed_in(System);
let zero = unsafe { zero.assume_init() };

assert_eq!(*zero, 0)
Source

pub fn new_cyclic_in<F>(data_fn: F, alloc: A) -> Arc<T, A>
where F: FnOnce(&Weak<T, A>) -> T,

🔬This is a nightly-only experimental API. (allocator_api)

Constructs a new Arc<T, A> in the given allocator while giving you a Weak<T, A> to the allocation, to allow you to construct a T which holds a weak pointer to itself.

Generally, a structure circularly referencing itself, either directly or indirectly, should not hold a strong reference to itself to prevent a memory leak. Using this function, you get access to the weak pointer during the initialization of T, before the Arc<T, A> is created, such that you can clone and store it inside the T.

new_cyclic_in first allocates the managed allocation for the Arc<T, A>, then calls your closure, giving it a Weak<T, A> to this allocation, and only afterwards completes the construction of the Arc<T, A> by placing the T returned from your closure into the allocation.

Since the new Arc<T, A> is not fully-constructed until Arc<T, A>::new_cyclic_in returns, calling upgrade on the weak reference inside your closure will fail and result in a None value.

§Panics

If data_fn panics, the panic is propagated to the caller, and the temporary Weak<T> is dropped normally.

§Example

See new_cyclic

Source

pub fn pin_in(data: T, alloc: A) -> Pin<Arc<T, A>>
where A: 'static,

🔬This is a nightly-only experimental API. (allocator_api)

Constructs a new Pin<Arc<T, A>> in the provided allocator. If T does not implement Unpin, then data will be pinned in memory and unable to be moved.

Source

pub fn try_pin_in(data: T, alloc: A) -> Result<Pin<Arc<T, A>>, AllocError>
where A: 'static,

🔬This is a nightly-only experimental API. (allocator_api)

Constructs a new Pin<Arc<T, A>> in the provided allocator, return an error if allocation fails.

Source

pub fn try_new_in(data: T, alloc: A) -> Result<Arc<T, A>, AllocError>

🔬This is a nightly-only experimental API. (allocator_api)

Constructs a new Arc<T, A> in the provided allocator, returning an error if allocation fails.

§Examples
#![feature(allocator_api)]

use std::sync::Arc;
use std::alloc::System;

let five = Arc::try_new_in(5, System)?;
Source

pub fn try_new_uninit_in(alloc: A) -> Result<Arc<MaybeUninit<T>, A>, AllocError>

🔬This is a nightly-only experimental API. (allocator_api)

Constructs a new Arc with uninitialized contents, in the provided allocator, returning an error if allocation fails.

§Examples
#![feature(allocator_api)]
#![feature(get_mut_unchecked)]

use std::sync::Arc;
use std::alloc::System;

let mut five = Arc::<u32, _>::try_new_uninit_in(System)?;

let five = unsafe {
    // Deferred initialization:
    Arc::get_mut_unchecked(&mut five).as_mut_ptr().write(5);

    five.assume_init()
};

assert_eq!(*five, 5);
Source

pub fn try_new_zeroed_in(alloc: A) -> Result<Arc<MaybeUninit<T>, A>, AllocError>

🔬This is a nightly-only experimental API. (allocator_api)

Constructs a new Arc with uninitialized contents, with the memory being filled with 0 bytes, in the provided allocator, returning an error if allocation fails.

See MaybeUninit::zeroed for examples of correct and incorrect usage of this method.

§Examples
#![feature(allocator_api)]

use std::sync::Arc;
use std::alloc::System;

let zero = Arc::<u32, _>::try_new_zeroed_in(System)?;
let zero = unsafe { zero.assume_init() };

assert_eq!(*zero, 0);
1.4.0 · Source

pub fn try_unwrap(this: Arc<T, A>) -> Result<T, Arc<T, A>>

Returns the inner value, if the Arc has exactly one strong reference.

Otherwise, an Err is returned with the same Arc that was passed in.

This will succeed even if there are outstanding weak references.

It is strongly recommended to use Arc::into_inner instead if you don’t keep the Arc in the Err case. Immediately dropping the Err-value, as the expression Arc::try_unwrap(this).ok() does, can cause the strong count to drop to zero and the inner value of the Arc to be dropped. For instance, if two threads execute such an expression in parallel, there is a race condition without the possibility of unsafety: The threads could first both check whether they own the last instance in Arc::try_unwrap, determine that they both do not, and then both discard and drop their instance in the call to ok. In this scenario, the value inside the Arc is safely destroyed by exactly one of the threads, but neither thread will ever be able to use the value.

§Examples
use std::sync::Arc;

let x = Arc::new(3);
assert_eq!(Arc::try_unwrap(x), Ok(3));

let x = Arc::new(4);
let _y = Arc::clone(&x);
assert_eq!(*Arc::try_unwrap(x).unwrap_err(), 4);
1.70.0 · Source

pub fn into_inner(this: Arc<T, A>) -> Option<T>

Returns the inner value, if the Arc has exactly one strong reference.

Otherwise, None is returned and the Arc is dropped.

This will succeed even if there are outstanding weak references.

If Arc::into_inner is called on every clone of this Arc, it is guaranteed that exactly one of the calls returns the inner value. This means in particular that the inner value is not dropped.

Arc::try_unwrap is conceptually similar to Arc::into_inner, but it is meant for different use-cases. If used as a direct replacement for Arc::into_inner anyway, such as with the expression Arc::try_unwrap(this).ok(), then it does not give the same guarantee as described in the previous paragraph. For more information, see the examples below and read the documentation of Arc::try_unwrap.

§Examples

Minimal example demonstrating the guarantee that Arc::into_inner gives.

use std::sync::Arc;

let x = Arc::new(3);
let y = Arc::clone(&x);

// Two threads calling `Arc::into_inner` on both clones of an `Arc`:
let x_thread = std::thread::spawn(|| Arc::into_inner(x));
let y_thread = std::thread::spawn(|| Arc::into_inner(y));

let x_inner_value = x_thread.join().unwrap();
let y_inner_value = y_thread.join().unwrap();

// One of the threads is guaranteed to receive the inner value:
assert!(matches!(
    (x_inner_value, y_inner_value),
    (None, Some(3)) | (Some(3), None)
));
// The result could also be `(None, None)` if the threads called
// `Arc::try_unwrap(x).ok()` and `Arc::try_unwrap(y).ok()` instead.

A more practical example demonstrating the need for Arc::into_inner:

use std::sync::Arc;

// Definition of a simple singly linked list using `Arc`:
#[derive(Clone)]
struct LinkedList<T>(Option<Arc<Node<T>>>);
struct Node<T>(T, Option<Arc<Node<T>>>);

// Dropping a long `LinkedList<T>` relying on the destructor of `Arc`
// can cause a stack overflow. To prevent this, we can provide a
// manual `Drop` implementation that does the destruction in a loop:
impl<T> Drop for LinkedList<T> {
    fn drop(&mut self) {
        let mut link = self.0.take();
        while let Some(arc_node) = link.take() {
            if let Some(Node(_value, next)) = Arc::into_inner(arc_node) {
                link = next;
            }
        }
    }
}

// Implementation of `new` and `push` omitted
impl<T> LinkedList<T> {
    /* ... */
}

// The following code could have still caused a stack overflow
// despite the manual `Drop` impl if that `Drop` impl had used
// `Arc::try_unwrap(arc).ok()` instead of `Arc::into_inner(arc)`.

// Create a long list and clone it
let mut x = LinkedList::new();
let size = 100000;
for i in 0..size {
    x.push(i); // Adds i to the front of x
}
let y = x.clone();

// Drop the clones in parallel
let x_thread = std::thread::spawn(|| drop(x));
let y_thread = std::thread::spawn(|| drop(y));
x_thread.join().unwrap();
y_thread.join().unwrap();

Trait Implementations

§

impl<T> AnyProvider for Arc<T>
where T: AnyProvider + ?Sized,

§

fn load_any( &self, key: DataKey, req: DataRequest<'_>, ) -> Result<AnyResponse, DataError>

Loads an [AnyPayload] according to the key and request.
§

impl<'a, A> Arbitrary<'a> for Arc<A>
where A: Arbitrary<'a>,

§

fn arbitrary(u: &mut Unstructured<'a>) -> Result<Arc<A>, Error>

Generate an arbitrary value of Self from the given unstructured data. Read more
§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
§

fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
§

impl<A> Arbitrary for Arc<A>
where A: Arbitrary,

§

type Parameters = <A as Arbitrary>::Parameters

The type of parameters that arbitrary_with accepts for configuration of the generated Strategy. Parameters must implement Default.
§

type Strategy = MapInto<<A as Arbitrary>::Strategy, Arc<A>>

The type of Strategy used to generate values of type Self.
§

fn arbitrary_with( args: <Arc<A> as Arbitrary>::Parameters, ) -> <Arc<A> as Arbitrary>::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). The strategy is passed the arguments given in args. Read more
§

fn arbitrary() -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). Read more
§

impl<A> ArbitraryF1<A> for Arc<A>
where A: Debug + 'static,

§

type Parameters = ()

The type of parameters that lift1_with accepts for configuration of the lifted and generated Strategy. Parameters must implement Default.
§

fn lift1_with<S>( base: S, _args: <Arc<A> as ArbitraryF1<A>>::Parameters, ) -> BoxedStrategy<Arc<A>>
where S: Strategy<Value = A> + 'static,

Lifts a given Strategy to a new Strategy for the (presumably) bigger type. This is useful for lifting a Strategy for SomeType to a container such as Vec of SomeType. The composite strategy is passed the arguments given in args. Read more
§

fn lift1<AS>(base: AS) -> BoxedStrategy<Self>
where AS: Strategy<Value = A> + 'static,

Lifts a given Strategy to a new Strategy for the (presumably) bigger type. This is useful for lifting a Strategy for SomeType to a container such as Vec<SomeType>. Read more
1.64.0 · Source§

impl<T> AsFd for Arc<T>
where T: AsFd + ?Sized,

This impl allows implementing traits that require AsFd on Arc.

use std::net::UdpSocket;
use std::sync::Arc;

trait MyTrait: AsFd {}
impl MyTrait for Arc<UdpSocket> {}
impl MyTrait for Box<UdpSocket> {}
Source§

fn as_fd(&self) -> BorrowedFd<'_>

Borrows the file descriptor. Read more
1.63.0 · Source§

impl<T> AsRawFd for Arc<T>
where T: AsRawFd,

This impl allows implementing traits that require AsRawFd on Arc.

use std::net::UdpSocket;
use std::sync::Arc;
trait MyTrait: AsRawFd {
}
impl MyTrait for Arc<UdpSocket> {}
impl MyTrait for Box<UdpSocket> {}
Source§

fn as_raw_fd(&self) -> i32

Extracts the raw file descriptor. Read more
1.5.0 · Source§

impl<T, A> AsRef<T> for Arc<T, A>
where A: Allocator, T: ?Sized,

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
§

impl<T> AsyncSleep for Arc<T>
where T: AsyncSleep + ?Sized,

§

fn sleep(&self, duration: Duration) -> Sleep

Returns a future that sleeps for the given duration of time.
§

impl<T> BlockHash for Arc<T>
where T: BlockHashRef,

§

type Error = <T as BlockHashRef>::Error

§

fn block_hash( &mut self, number: u64, ) -> Result<FixedBytes<32>, <Arc<T> as BlockHash>::Error>

Get block hash by block number
§

impl<T> BlockHashRef for Arc<T>
where T: BlockHashRef + ?Sized,

§

type Error = <T as BlockHashRef>::Error

§

fn block_hash( &self, number: u64, ) -> Result<FixedBytes<32>, <Arc<T> as BlockHashRef>::Error>

Get block hash by block number
§

impl<T> BlockHeader for Arc<T>
where T: BlockHeader + ?Sized,

§

fn parent_hash(&self) -> FixedBytes<32>

Retrieves the parent hash of the block
§

fn ommers_hash(&self) -> FixedBytes<32>

Retrieves the ommers hash of the block
§

fn beneficiary(&self) -> Address

Retrieves the beneficiary (miner) of the block
§

fn state_root(&self) -> FixedBytes<32>

Retrieves the state root hash of the block
§

fn transactions_root(&self) -> FixedBytes<32>

Retrieves the transactions root hash of the block
§

fn receipts_root(&self) -> FixedBytes<32>

Retrieves the receipts root hash of the block
§

fn withdrawals_root(&self) -> Option<FixedBytes<32>>

Retrieves the withdrawals root hash of the block, if available
§

fn logs_bloom(&self) -> Bloom

Retrieves the logs bloom filter of the block
§

fn difficulty(&self) -> Uint<256, 4>

Retrieves the difficulty of the block
§

fn number(&self) -> u64

Retrieves the block number
§

fn gas_limit(&self) -> u64

Retrieves the gas limit of the block
§

fn gas_used(&self) -> u64

Retrieves the gas used by the block
§

fn timestamp(&self) -> u64

Retrieves the timestamp of the block
§

fn mix_hash(&self) -> Option<FixedBytes<32>>

Retrieves the mix hash of the block, if available
§

fn nonce(&self) -> Option<FixedBytes<8>>

Retrieves the nonce of the block, if avaialble
§

fn base_fee_per_gas(&self) -> Option<u64>

Retrieves the base fee per gas of the block, if available
§

fn blob_gas_used(&self) -> Option<u64>

Retrieves the blob gas used by the block, if available
§

fn excess_blob_gas(&self) -> Option<u64>

Retrieves the excess blob gas of the block, if available
§

fn parent_beacon_block_root(&self) -> Option<FixedBytes<32>>

Retrieves the parent beacon block root of the block, if available
§

fn requests_hash(&self) -> Option<FixedBytes<32>>

Retrieves the requests hash of the block, if available
§

fn extra_data(&self) -> &Bytes

Retrieves the block’s extra data field
§

fn blob_fee(&self, blob_params: BlobParams) -> Option<u128>

Returns the blob fee for this block according to the EIP-4844 spec. Read more
§

fn next_block_excess_blob_gas(&self, blob_params: BlobParams) -> Option<u64>

Calculate excess blob gas for the next block according to the EIP-4844 spec. Read more
§

fn maybe_next_block_excess_blob_gas( &self, blob_params: Option<BlobParams>, ) -> Option<u64>

Convenience function for [Self::next_block_excess_blob_gas] with an optional [BlobParams] argument. Read more
§

fn next_block_blob_fee(&self, blob_params: BlobParams) -> Option<u128>

Returns the blob fee for the next block according to the EIP-4844 spec. Read more
§

fn maybe_next_block_blob_fee( &self, blob_params: Option<BlobParams>, ) -> Option<u128>

Convenience function for [Self::next_block_blob_fee] with an optional [BlobParams] argument. Read more
§

fn next_block_base_fee(&self, base_fee_params: BaseFeeParams) -> Option<u64>

Calculate base fee for next block according to the EIP-1559 spec. Read more
§

fn parent_num_hash(&self) -> NumHash

Returns the parent block’s number and hash Read more
§

fn is_empty(&self) -> bool

Checks if the header is considered empty - has no transactions, no ommers or withdrawals
§

fn is_zero_difficulty(&self) -> bool

Checks if the block’s difficulty is set to zero, indicating a Proof-of-Stake header. Read more
§

fn exceeds_allowed_future_timestamp(&self, present_timestamp: u64) -> bool

Checks if the block’s timestamp is in the future based on the present timestamp. Read more
§

fn is_nonce_zero(&self) -> bool

Checks if the nonce exists, and if it exists, if it’s zero. Read more
1.0.0 · Source§

impl<T, A> Borrow<T> for Arc<T, A>
where A: Allocator, T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<M, P> BoundDataProvider<M> for Arc<P>
where M: DataMarker, P: BoundDataProvider<M> + ?Sized,

§

fn load_bound(&self, req: DataRequest<'_>) -> Result<DataResponse<M>, DataError>

Query the provider for data, returning the result. Read more
§

fn bound_key(&self) -> DataKey

Returns the [DataKey] that this provider uses for loading data.
§

impl<T> BufferProvider for Arc<T>
where T: BufferProvider + ?Sized,

§

fn load_buffer( &self, key: DataKey, req: DataRequest<'_>, ) -> Result<DataResponse<BufferMarker>, DataError>

Loads a [DataPayload]<[BufferMarker]> according to the key and request.
1.0.0 · Source§

impl<T, A> Clone for Arc<T, A>
where A: Allocator + Clone, T: ?Sized,

Source§

fn clone(&self) -> Arc<T, A>

Makes a clone of the Arc pointer.

This creates another pointer to the same allocation, increasing the strong reference count.

§Examples
use std::sync::Arc;

let five = Arc::new(5);

let _ = Arc::clone(&five);
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
§

impl<T> CodeLocation for Arc<T>
where T: CodeLocation + ?Sized,

§

fn loc(&self) -> Loc

Returns the code location of self.
§

impl<T> CodeLocationExt for Arc<T>
where T: CodeLocationExt + ?Sized,

§

fn loc(&self) -> Loc

Returns the code location of self.
§

impl<T> Compiler for Arc<T>
where T: Compiler + ?Sized, Arc<T>: Send + Sync + Clone,

§

type Input = <T as Compiler>::Input

Input type for the compiler. Contains settings and sources to be compiled.
§

type CompilationError = <T as Compiler>::CompilationError

Error type returned by the compiler.
§

type CompilerContract = <T as Compiler>::CompilerContract

Output data for each contract
§

type ParsedSource = <T as Compiler>::ParsedSource

Source parser used for resolving imports and version requirements.
§

type Settings = <T as Compiler>::Settings

Compiler settings.
§

type Language = <T as Compiler>::Language

Enum of languages supported by the compiler.
§

fn compile( &self, input: &<Arc<T> as Compiler>::Input, ) -> Result<CompilerOutput<<Arc<T> as Compiler>::CompilationError, <Arc<T> as Compiler>::CompilerContract>, SolcError>

Main entrypoint for the compiler. Compiles given input into [CompilerOutput]. Takes ownership over the input and returns back version with potential modifications made to it. Returned input is always the one which was seen by the binary.
§

fn available_versions( &self, language: &<Arc<T> as Compiler>::Language, ) -> Vec<CompilerVersion>

Returns all versions available locally and remotely. Should return versions with stripped metadata.
§

impl<M, P> DataProvider<M> for Arc<P>
where M: KeyedDataMarker, P: DataProvider<M> + ?Sized,

§

fn load(&self, req: DataRequest<'_>) -> Result<DataResponse<M>, DataError>

Query the provider for data, returning the result. Read more
§

impl<T> DatabaseRef for Arc<T>
where T: DatabaseRef + ?Sized,

§

type Error = <T as DatabaseRef>::Error

The database error type.
§

fn basic_ref( &self, address: Address, ) -> Result<Option<AccountInfo>, <Arc<T> as DatabaseRef>::Error>

Get basic account information.
§

fn code_by_hash_ref( &self, code_hash: FixedBytes<32>, ) -> Result<Bytecode, <Arc<T> as DatabaseRef>::Error>

Get account code by its hash.
§

fn storage_ref( &self, address: Address, index: Uint<256, 4>, ) -> Result<Uint<256, 4>, <Arc<T> as DatabaseRef>::Error>

Get storage value of address at index.
§

fn block_hash_ref( &self, number: u64, ) -> Result<FixedBytes<32>, <Arc<T> as DatabaseRef>::Error>

Get block hash by block number.
1.0.0 · Source§

impl<T, A> Debug for Arc<T, A>
where T: Debug + ?Sized, A: Allocator,

Source§

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

Formats the value using the given formatter. Read more
§

impl<T> Decodable for Arc<T>
where T: Decodable,

§

fn decode(buf: &mut &[u8]) -> Result<Arc<T>, Error>

Decodes the blob into the appropriate type. buf must be advanced past the decoded object.
1.0.0 · Source§

impl<T> Default for Arc<T>
where T: Default,

Source§

fn default() -> Arc<T>

Creates a new Arc<T>, with the Default value for T.

§Examples
use std::sync::Arc;

let x: Arc<i32> = Default::default();
assert_eq!(*x, 0);
1.0.0 · Source§

impl<T, A> Deref for Arc<T, A>
where A: Allocator, T: ?Sized,

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &T

Dereferences the value.
Source§

impl<'de, T> Deserialize<'de> for Arc<T>
where Box<T>: Deserialize<'de>, T: ?Sized,

This impl requires the "rc" Cargo feature of Serde.

Deserializing a data structure containing Arc will not attempt to deduplicate Arc references to the same data. Every deserialized Arc will end up with a strong count of 1.

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Arc<T>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
1.0.0 · Source§

impl<T, A> Display for Arc<T, A>
where T: Display + ?Sized, A: Allocator,

Source§

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

Formats the value using the given formatter. Read more
1.0.0 · Source§

impl<T, A> Drop for Arc<T, A>
where A: Allocator, T: ?Sized,

Source§

fn drop(&mut self)

Drops the Arc.

This will decrement the strong reference count. If the strong reference count reaches zero then the only other references (if any) are Weak, so we drop the inner value.

§Examples
use std::sync::Arc;

struct Foo;

impl Drop for Foo {
    fn drop(&mut self) {
        println!("dropped!");
    }
}

let foo  = Arc::new(Foo);
let foo2 = Arc::clone(&foo);

drop(foo);    // Doesn't print anything
drop(foo2);   // Prints "dropped!"
§

impl<M, P> DynamicDataProvider<M> for Arc<P>
where M: DataMarker, P: DynamicDataProvider<M> + ?Sized,

§

fn load_data( &self, key: DataKey, req: DataRequest<'_>, ) -> Result<DataResponse<M>, DataError>

Query the provider for data, returning the result. Read more
§

impl<T> Encodable for Arc<T>
where T: Encodable + ?Sized,

§

fn length(&self) -> usize

Returns the length of the encoding of this type in bytes. Read more
§

fn encode(&self, out: &mut dyn BufMut)

Encodes the type into the out buffer.
1.52.0 · Source§

impl<T> Error for Arc<T>
where T: Error + ?Sized,

Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
Source§

fn provide<'a>(&'a self, req: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
1.21.0 · Source§

impl<T, A> From<Box<T, A>> for Arc<T, A>
where A: Allocator, T: ?Sized,

Source§

fn from(v: Box<T, A>) -> Arc<T, A>

Move a boxed object to a new, reference-counted allocation.

§Example
let unique: Box<str> = Box::from("eggplant");
let shared: Arc<str> = Arc::from(unique);
assert_eq!("eggplant", &shared[..]);
1.45.0 · Source§

impl<'a, B> From<Cow<'a, B>> for Arc<B>
where B: ToOwned + ?Sized, Arc<B>: From<&'a B> + From<<B as ToOwned>::Owned>,

Source§

fn from(cow: Cow<'a, B>) -> Arc<B>

Creates an atomically reference-counted pointer from a clone-on-write pointer by copying its content.

§Example
let cow: Cow<'_, str> = Cow::Borrowed("eggplant");
let shared: Arc<str> = Arc::from(cow);
assert_eq!("eggplant", &shared[..]);
1.6.0 · Source§

impl<T> From<T> for Arc<T>

Source§

fn from(t: T) -> Arc<T>

Converts a T into an Arc<T>

The conversion moves the value into a newly allocated Arc. It is equivalent to calling Arc::new(t).

§Example
let x = 5;
let arc = Arc::new(5);

assert_eq!(Arc::from(x), arc);
§

impl<T> FromHex for Arc<T>
where T: FromHex,

§

type Error = <T as FromHex>::Error

The associated error which can be returned from parsing.
§

fn from_hex<U>(hex: U) -> Result<Arc<T>, <Arc<T> as FromHex>::Error>
where U: AsRef<[u8]>,

Creates an instance of type Self from the given hex string, or fails with a custom error type. Read more
1.0.0 · Source§

impl<T, A> Hash for Arc<T, A>
where T: Hash + ?Sized, A: Allocator,

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl<T> JsonSchema for Arc<T>
where T: JsonSchema + ?Sized,

§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
§

impl<Sp> LocalSpawn for Arc<Sp>
where Sp: LocalSpawn + ?Sized,

§

fn spawn_local_obj( &self, future: LocalFutureObj<'static, ()>, ) -> Result<(), SpawnError>

Spawns a future that will be run to completion. Read more
§

fn status_local(&self) -> Result<(), SpawnError>

Determines whether the executor is able to spawn new tasks. Read more
Source§

impl<T> Log for Arc<T>
where T: Log + ?Sized,

Source§

fn enabled(&self, metadata: &Metadata<'_>) -> bool

Determines if a log message with the specified metadata would be logged. Read more
Source§

fn log(&self, record: &Record<'_>)

Logs the Record. Read more
Source§

fn flush(&self)

Flushes any buffered records. Read more
§

impl<'a, W> MakeWriter<'a> for Arc<W>
where &'a W: Write + 'a,

§

type Writer = &'a W

The concrete io::Write implementation returned by make_writer.
§

fn make_writer(&'a self) -> <Arc<W> as MakeWriter<'a>>::Writer

Returns an instance of Writer. Read more
§

fn make_writer_for(&'a self, meta: &Metadata<'_>) -> Self::Writer

Returns a Writer for writing data from the span or event described by the provided Metadata. Read more
§

impl<N, T> NetworkWallet<N> for Arc<T>
where N: Network, T: NetworkWallet<N> + ?Sized, Arc<T>: Debug + Send + Sync,

§

fn default_signer_address(&self) -> Address

Get the default signer address. This address should be used in [NetworkWallet::sign_transaction_from] when no specific signer is specified.
§

fn has_signer_for(&self, address: &Address) -> bool

Return true if the signer contains a credential for the given address.
§

fn signer_addresses(&self) -> impl Iterator<Item = Address>

Return an iterator of all signer addresses.
§

fn sign_transaction_from( &self, sender: Address, tx: <N as Network>::UnsignedTx, ) -> impl Send + Future<Output = Result<<N as Network>::TxEnvelope, Error>>

Asynchronously sign an unsigned transaction, with a specified credential.
§

fn sign_transaction( &self, tx: <N as Network>::UnsignedTx, ) -> impl Send + Future<Output = Result<<N as Network>::TxEnvelope, Error>>

Asynchronously sign an unsigned transaction.
§

fn sign_request( &self, request: <N as Network>::TransactionRequest, ) -> impl Send + Future<Output = Result<<N as Network>::TxEnvelope, Error>>

Asynchronously sign a transaction request, using the sender specified in the from field.
§

impl<T> OptionalCodeLocation for Arc<T>
where T: OptionalCodeLocation + ?Sized,

§

fn loc_opt(&self) -> Option<Loc>

Returns the optional code location of self.
1.0.0 · Source§

impl<T, A> Ord for Arc<T, A>
where T: Ord + ?Sized, A: Allocator,

Source§

fn cmp(&self, other: &Arc<T, A>) -> Ordering

Comparison for two Arcs.

The two are compared by calling cmp() on their inner values.

§Examples
use std::sync::Arc;
use std::cmp::Ordering;

let five = Arc::new(5);

assert_eq!(Ordering::Less, five.cmp(&Arc::new(6)));
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
1.0.0 · Source§

impl<T, A> PartialEq for Arc<T, A>
where T: PartialEq + ?Sized, A: Allocator,

Source§

fn eq(&self, other: &Arc<T, A>) -> bool

Equality for two Arcs.

Two Arcs are equal if their inner values are equal, even if they are stored in different allocation.

If T also implements Eq (implying reflexivity of equality), two Arcs that point to the same allocation are always equal.

§Examples
use std::sync::Arc;

let five = Arc::new(5);

assert!(five == Arc::new(5));
Source§

fn ne(&self, other: &Arc<T, A>) -> bool

Inequality for two Arcs.

Two Arcs are not equal if their inner values are not equal.

If T also implements Eq (implying reflexivity of equality), two Arcs that point to the same value are always equal.

§Examples
use std::sync::Arc;

let five = Arc::new(5);

assert!(five != Arc::new(6));
1.0.0 · Source§

impl<T, A> PartialOrd for Arc<T, A>
where T: PartialOrd + ?Sized, A: Allocator,

Source§

fn partial_cmp(&self, other: &Arc<T, A>) -> Option<Ordering>

Partial comparison for two Arcs.

The two are compared by calling partial_cmp() on their inner values.

§Examples
use std::sync::Arc;
use std::cmp::Ordering;

let five = Arc::new(5);

assert_eq!(Some(Ordering::Less), five.partial_cmp(&Arc::new(6)));
Source§

fn lt(&self, other: &Arc<T, A>) -> bool

Less-than comparison for two Arcs.

The two are compared by calling < on their inner values.

§Examples
use std::sync::Arc;

let five = Arc::new(5);

assert!(five < Arc::new(6));
Source§

fn le(&self, other: &Arc<T, A>) -> bool

‘Less than or equal to’ comparison for two Arcs.

The two are compared by calling <= on their inner values.

§Examples
use std::sync::Arc;

let five = Arc::new(5);

assert!(five <= Arc::new(5));
Source§

fn gt(&self, other: &Arc<T, A>) -> bool

Greater-than comparison for two Arcs.

The two are compared by calling > on their inner values.

§Examples
use std::sync::Arc;

let five = Arc::new(5);

assert!(five > Arc::new(4));
Source§

fn ge(&self, other: &Arc<T, A>) -> bool

‘Greater than or equal to’ comparison for two Arcs.

The two are compared by calling >= on their inner values.

§Examples
use std::sync::Arc;

let five = Arc::new(5);

assert!(five >= Arc::new(5));
1.0.0 · Source§

impl<T, A> Pointer for Arc<T, A>
where A: Allocator, T: ?Sized,

Source§

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

Formats the value using the given formatter. Read more
§

impl<N, T> Provider<N> for Arc<T>
where N: Network, T: Provider<N>, Arc<T>: Send + Sync,

§

fn root(&self) -> &RootProvider<N>

Returns the root provider.
§

fn builder() -> ProviderBuilder<Identity, Identity, N>
where Arc<T>: Sized,

Returns the ProviderBuilder to build on.
§

fn client(&self) -> &RpcClientInner

Returns the RPC client used to send requests. Read more
§

fn weak_client(&self) -> Weak<RpcClientInner>

Returns a Weak RPC client used to send requests. Read more
§

fn get_accounts(&self) -> ProviderCall<[(); 0], Vec<Address>>

Gets the accounts in the remote node. This is usually empty unless you’re using a local node.
§

fn get_blob_base_fee(&self) -> ProviderCall<[(); 0], Uint<128, 2>, u128>

Returns the base fee per blob gas (blob gas price) in wei.
§

fn get_block_number(&self) -> ProviderCall<[(); 0], Uint<64, 1>, u64>

Get the last block number available.
§

fn call(&self, tx: <N as Network>::TransactionRequest) -> EthCall<N, Bytes>

Execute a smart contract call with a transaction request and state overrides, without publishing a transaction. Read more
§

fn call_many<'req>( &self, bundles: &'req Vec<Bundle>, ) -> EthCallMany<'req, N, Vec<Vec<EthCallResponse>>>

Execute a list of [Bundle] against the provided StateContext and StateOverride, without publishing a transaction. Read more
§

fn simulate<'req>( &self, payload: &'req SimulatePayload, ) -> RpcWithBlock<&'req SimulatePayload, Vec<SimulatedBlock<<N as Network>::BlockResponse>>>

Executes an arbitrary number of transactions on top of the requested state. Read more
§

fn get_chain_id(&self) -> ProviderCall<[(); 0], Uint<64, 1>, u64>

Gets the chain ID.
§

fn create_access_list<'a>( &self, request: &'a <N as Network>::TransactionRequest, ) -> RpcWithBlock<&'a <N as Network>::TransactionRequest, AccessListResult>

Create an EIP-2930 access list.
§

fn estimate_gas( &self, tx: <N as Network>::TransactionRequest, ) -> EthCall<N, Uint<64, 1>, u64>

Create an [EthCall] future to estimate the gas required for a transaction. Read more
§

fn estimate_eip1559_fees_with<'life0, 'async_trait>( &'life0 self, estimator: Eip1559Estimator, ) -> Pin<Box<dyn Future<Output = Result<Eip1559Estimation, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Estimates the EIP1559 maxFeePerGas and maxPriorityFeePerGas fields. Read more
§

fn estimate_eip1559_fees<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Eip1559Estimation, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Estimates the EIP1559 maxFeePerGas and maxPriorityFeePerGas fields. Read more
§

fn get_fee_history<'life0, 'life1, 'async_trait>( &'life0 self, block_count: u64, last_block: BlockNumberOrTag, reward_percentiles: &'life1 [f64], ) -> Pin<Box<dyn Future<Output = Result<FeeHistory, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Arc<T>: 'async_trait,

Returns a collection of historical gas information [FeeHistory] which can be used to calculate the EIP1559 fields maxFeePerGas and maxPriorityFeePerGas. block_count can range from 1 to 1024 blocks in a single request.
§

fn get_gas_price(&self) -> ProviderCall<[(); 0], Uint<128, 2>, u128>

Gets the current gas price in wei.
§

fn get_account(&self, address: Address) -> RpcWithBlock<Address, TrieAccount>

Retrieves account information (Account) for the given [Address] at the particular [BlockId].
§

fn get_balance(&self, address: Address) -> RpcWithBlock<Address, Uint<256, 4>>

Gets the balance of the account. Read more
§

fn get_block( &self, block: BlockId, ) -> EthGetBlock<<N as Network>::BlockResponse>

Gets a block by either its hash, tag, or number Read more
§

fn get_block_by_hash( &self, hash: FixedBytes<32>, ) -> EthGetBlock<<N as Network>::BlockResponse>

Gets a block by its [BlockHash] Read more
§

fn get_block_by_number( &self, number: BlockNumberOrTag, ) -> EthGetBlock<<N as Network>::BlockResponse>

Gets a block by its [BlockNumberOrTag] Read more
§

fn get_block_transaction_count_by_hash<'life0, 'async_trait>( &'life0 self, hash: FixedBytes<32>, ) -> Pin<Box<dyn Future<Output = Result<Option<u64>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Returns the number of transactions in a block from a block matching the given block hash.
§

fn get_block_transaction_count_by_number<'life0, 'async_trait>( &'life0 self, block_number: BlockNumberOrTag, ) -> Pin<Box<dyn Future<Output = Result<Option<u64>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Returns the number of transactions in a block matching the given block number.
§

fn get_block_receipts( &self, block: BlockId, ) -> ProviderCall<(BlockId,), Option<Vec<<N as Network>::ReceiptResponse>>>

Gets the selected block [BlockId] receipts.
§

fn get_code_at(&self, address: Address) -> RpcWithBlock<Address, Bytes>

Gets the bytecode located at the corresponding [Address].
§

fn watch_blocks<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<PollerBuilder<(Uint<256, 4>,), Vec<FixedBytes<32>>>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Watch for new blocks by polling the provider with eth_getFilterChanges. Read more
§

fn watch_pending_transactions<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<PollerBuilder<(Uint<256, 4>,), Vec<FixedBytes<32>>>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Watch for new pending transaction by polling the provider with eth_getFilterChanges. Read more
§

fn watch_logs<'life0, 'life1, 'async_trait>( &'life0 self, filter: &'life1 Filter, ) -> Pin<Box<dyn Future<Output = Result<PollerBuilder<(Uint<256, 4>,), Vec<Log>>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Arc<T>: 'async_trait,

Watch for new logs using the given filter by polling the provider with eth_getFilterChanges. Read more
§

fn watch_full_pending_transactions<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<PollerBuilder<(Uint<256, 4>,), Vec<<N as Network>::TransactionResponse>>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Watch for new pending transaction bodies by polling the provider with eth_getFilterChanges. Read more
§

fn get_filter_changes_dyn<'life0, 'async_trait>( &'life0 self, id: Uint<256, 4>, ) -> Pin<Box<dyn Future<Output = Result<FilterChanges, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Get a list of values that have been added since the last poll. Read more
§

fn get_filter_logs<'life0, 'async_trait>( &'life0 self, id: Uint<256, 4>, ) -> Pin<Box<dyn Future<Output = Result<Vec<Log>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Retrieves a Vec<Log> for the given filter ID.
§

fn uninstall_filter<'life0, 'async_trait>( &'life0 self, id: Uint<256, 4>, ) -> Pin<Box<dyn Future<Output = Result<bool, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Request provider to uninstall the filter with the given ID.
§

fn watch_pending_transaction<'life0, 'async_trait>( &'life0 self, config: PendingTransactionConfig, ) -> Pin<Box<dyn Future<Output = Result<PendingTransaction, PendingTransactionError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Watch for the confirmation of a single pending transaction with the given configuration. Read more
§

fn get_logs<'life0, 'life1, 'async_trait>( &'life0 self, filter: &'life1 Filter, ) -> Pin<Box<dyn Future<Output = Result<Vec<Log>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Arc<T>: 'async_trait,

Retrieves a Vec<Log> with the given [Filter].
§

fn get_proof( &self, address: Address, keys: Vec<FixedBytes<32>>, ) -> RpcWithBlock<(Address, Vec<FixedBytes<32>>), EIP1186AccountProofResponse>

Get the account and storage values of the specified account including the merkle proofs. Read more
§

fn get_storage_at( &self, address: Address, key: Uint<256, 4>, ) -> RpcWithBlock<(Address, Uint<256, 4>), Uint<256, 4>>

Gets the specified storage value from [Address].
§

fn get_transaction_by_hash( &self, hash: FixedBytes<32>, ) -> ProviderCall<(FixedBytes<32>,), Option<<N as Network>::TransactionResponse>>

Gets a transaction by its [TxHash].
§

fn get_transaction_by_block_hash_and_index( &self, block_hash: FixedBytes<32>, index: usize, ) -> ProviderCall<(FixedBytes<32>, Index), Option<<N as Network>::TransactionResponse>>

Gets a transaction by block hash and transaction index position.
§

fn get_raw_transaction_by_block_hash_and_index( &self, block_hash: FixedBytes<32>, index: usize, ) -> ProviderCall<(FixedBytes<32>, Index), Option<Bytes>>

Gets a raw transaction by block hash and transaction index position.
§

fn get_transaction_by_block_number_and_index( &self, block_number: BlockNumberOrTag, index: usize, ) -> ProviderCall<(BlockNumberOrTag, Index), Option<<N as Network>::TransactionResponse>>

Gets a transaction by block number and transaction index position.
§

fn get_raw_transaction_by_block_number_and_index( &self, block_number: BlockNumberOrTag, index: usize, ) -> ProviderCall<(BlockNumberOrTag, Index), Option<Bytes>>

Gets a raw transaction by block number and transaction index position.
§

fn get_raw_transaction_by_hash( &self, hash: FixedBytes<32>, ) -> ProviderCall<(FixedBytes<32>,), Option<Bytes>>

Returns the EIP-2718 encoded transaction if it exists, see also Decodable2718. Read more
§

fn get_transaction_count( &self, address: Address, ) -> RpcWithBlock<Address, Uint<64, 1>, u64>

Gets the transaction count (AKA “nonce”) of the corresponding address.
§

fn get_transaction_receipt( &self, hash: FixedBytes<32>, ) -> ProviderCall<(FixedBytes<32>,), Option<<N as Network>::ReceiptResponse>>

Gets a transaction receipt if it exists, by its [TxHash].
§

fn get_uncle<'life0, 'async_trait>( &'life0 self, tag: BlockId, idx: u64, ) -> Pin<Box<dyn Future<Output = Result<Option<<N as Network>::BlockResponse>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Gets an uncle block through the tag [BlockId] and index u64.
§

fn get_uncle_count<'life0, 'async_trait>( &'life0 self, tag: BlockId, ) -> Pin<Box<dyn Future<Output = Result<u64, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Gets the number of uncles for the block specified by the tag [BlockId].
§

fn get_max_priority_fee_per_gas( &self, ) -> ProviderCall<[(); 0], Uint<128, 2>, u128>

Returns a suggestion for the current maxPriorityFeePerGas in wei.
§

fn new_block_filter<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Uint<256, 4>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Notify the provider that we are interested in new blocks. Read more
§

fn new_filter<'life0, 'life1, 'async_trait>( &'life0 self, filter: &'life1 Filter, ) -> Pin<Box<dyn Future<Output = Result<Uint<256, 4>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Arc<T>: 'async_trait,

Notify the provider that we are interested in logs that match the given filter. Read more
§

fn new_pending_transactions_filter<'life0, 'async_trait>( &'life0 self, full: bool, ) -> Pin<Box<dyn Future<Output = Result<Uint<256, 4>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Notify the provider that we are interested in new pending transactions. Read more
§

fn send_raw_transaction<'life0, 'life1, 'async_trait>( &'life0 self, encoded_tx: &'life1 [u8], ) -> Pin<Box<dyn Future<Output = Result<PendingTransactionBuilder<N>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Arc<T>: 'async_trait,

Broadcasts a raw transaction RLP bytes to the network. Read more
§

fn send_raw_transaction_conditional<'life0, 'life1, 'async_trait>( &'life0 self, encoded_tx: &'life1 [u8], conditional: TransactionConditional, ) -> Pin<Box<dyn Future<Output = Result<PendingTransactionBuilder<N>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Arc<T>: 'async_trait,

Broadcasts a raw transaction RLP bytes with a conditional [TransactionConditional] to the network. Read more
§

fn send_transaction<'life0, 'async_trait>( &'life0 self, tx: <N as Network>::TransactionRequest, ) -> Pin<Box<dyn Future<Output = Result<PendingTransactionBuilder<N>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Broadcasts a transaction to the network. Read more
§

fn send_tx_envelope<'life0, 'async_trait>( &'life0 self, tx: <N as Network>::TxEnvelope, ) -> Pin<Box<dyn Future<Output = Result<PendingTransactionBuilder<N>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Broadcasts a transaction envelope to the network. Read more
§

fn subscribe_blocks<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Subscription<<N as Network>::HeaderResponse>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Subscribe to a stream of new block headers. Read more
§

fn subscribe_pending_transactions<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Subscription<FixedBytes<32>>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Subscribe to a stream of pending transaction hashes. Read more
§

fn subscribe_full_pending_transactions<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Subscription<<N as Network>::TransactionResponse>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Subscribe to a stream of pending transaction bodies. Read more
§

fn subscribe_logs<'life0, 'life1, 'async_trait>( &'life0 self, filter: &'life1 Filter, ) -> Pin<Box<dyn Future<Output = Result<Subscription<Log>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Arc<T>: 'async_trait,

Subscribe to a stream of logs matching given filter. Read more
§

fn unsubscribe<'life0, 'async_trait>( &'life0 self, id: FixedBytes<32>, ) -> Pin<Box<dyn Future<Output = Result<(), RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Cancels a subscription given the subscription ID.
§

fn syncing(&self) -> ProviderCall<[(); 0], SyncStatus>

Gets syncing info.
§

fn get_client_version(&self) -> ProviderCall<[(); 0], String>

Gets the client version.
§

fn get_sha3(&self, data: &[u8]) -> ProviderCall<(String,), FixedBytes<32>>

Gets the Keccak-256 hash of the given data.
§

fn get_net_version(&self) -> ProviderCall<[(); 0], Uint<64, 1>, u64>

Gets the network ID. Same as eth_chainId.
§

fn raw_request<'life0, 'async_trait, P, R>( &'life0 self, method: Cow<'static, str>, params: P, ) -> Pin<Box<dyn Future<Output = Result<R, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, P: RpcSend + 'async_trait, R: RpcRecv + 'async_trait, Arc<T>: Sized + 'async_trait,

Sends a raw JSON-RPC request. Read more
§

fn raw_request_dyn<'life0, 'life1, 'async_trait>( &'life0 self, method: Cow<'static, str>, params: &'life1 RawValue, ) -> Pin<Box<dyn Future<Output = Result<Box<RawValue>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Arc<T>: 'async_trait,

Sends a raw JSON-RPC request with type-erased parameters and return. Read more
§

fn transaction_request(&self) -> <N as Network>::TransactionRequest

Creates a new TransactionRequest.
§

fn erased(self) -> DynProvider<N>
where Self: Sized + 'static,

Returns a type erased provider wrapped in Arc. See [DynProvider]. Read more
§

fn multicall(&self) -> MulticallBuilder<Empty, &Self, N>
where Self: Sized,

Execute a multicall by leveraging the [MulticallBuilder]. Read more
§

fn get_filter_changes<'life0, 'async_trait, R>( &'life0 self, id: Uint<256, 4>, ) -> Pin<Box<dyn Future<Output = Result<Vec<R>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: Sized + 'async_trait, R: 'async_trait + RpcRecv,

Get a list of values that have been added since the last poll. Read more
§

fn subscribe<'life0, 'async_trait, P, R>( &'life0 self, params: P, ) -> Pin<Box<dyn Future<Output = Result<Subscription<R>, RpcError<TransportErrorKind>>> + Send + 'async_trait>>
where 'life0: 'async_trait, P: RpcSend + 'async_trait, R: RpcRecv + 'async_trait, Self: Sized + 'async_trait,

Subscribe to an RPC event.
Source§

impl<T> Serialize for Arc<T>
where T: Serialize + ?Sized,

This impl requires the "rc" Cargo feature of Serde.

Serializing a data structure containing Arc will serialize a copy of the contents of the Arc each time the Arc is referenced within the data structure. Serialization will not attempt to deduplicate these repeated data.

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl<Request, S> Service<Request> for Arc<S>
where S: Service<Request> + ?Sized,

§

type Response = <S as Service<Request>>::Response

Responses given by the service.
§

type Error = <S as Service<Request>>::Error

Errors produced by the service. Read more
§

type Future = <S as Service<Request>>::Future

The future response value.
§

fn call(&self, req: Request) -> <Arc<S> as Service<Request>>::Future

Process the request and return the response asynchronously. call takes &self instead of mut &self because: Read more
§

impl<Sig, U> SignerSync<Sig> for Arc<U>
where U: SignerSync<Sig> + ?Sized,

§

fn sign_hash_sync(&self, hash: &FixedBytes<32>) -> Result<Sig, Error>

Signs the given hash.
§

fn sign_message_sync(&self, message: &[u8]) -> Result<Sig, Error>

Signs the hash of the provided message after prefixing it, as specified in EIP-191.
§

fn sign_dynamic_typed_data_sync( &self, payload: &TypedData, ) -> Result<Sig, Error>

Encodes and signs the typed data according to EIP-712 for Signers that are not dynamically sized.
§

fn chain_id_sync(&self) -> Option<u64>

Returns the signer’s chain ID.
§

fn sign_typed_data_sync<T>( &self, payload: &T, domain: &Eip712Domain, ) -> Result<Sig, Error>
where T: SolStruct, Self: Sized,

Encodes and signs the typed data according to EIP-712.
Source§

impl<S> Source for Arc<S>
where S: Source + ?Sized,

Source§

fn visit<'kvs>( &'kvs self, visitor: &mut dyn VisitSource<'kvs>, ) -> Result<(), Error>

Visit key-values. Read more
Source§

fn get(&self, key: Key<'_>) -> Option<Value<'_>>

Get the value for a given key. Read more
Source§

fn count(&self) -> usize

Count the number of key-values that can be visited. Read more
§

impl<Sp> Spawn for Arc<Sp>
where Sp: Spawn + ?Sized,

§

fn spawn_obj(&self, future: FutureObj<'static, ()>) -> Result<(), SpawnError>

Spawns a future that will be run to completion. Read more
§

fn status(&self) -> Result<(), SpawnError>

Determines whether the executor is able to spawn new tasks. Read more
§

impl<T> Specifier<DynSolType> for Arc<T>
where T: Specifier<DynSolType> + ?Sized,

§

fn resolve(&self) -> Result<DynSolType, Error>

Resolve the type into a value.
§

impl<T> State for Arc<T>
where T: StateRef,

§

type Error = <T as StateRef>::Error

§

fn basic( &mut self, address: Address, ) -> Result<Option<AccountInfo>, <Arc<T> as State>::Error>

Get basic account information.
§

fn code_by_hash( &mut self, code_hash: FixedBytes<32>, ) -> Result<Bytecode, <Arc<T> as State>::Error>

Get account code by its hash
§

fn storage( &mut self, address: Address, index: Uint<256, 4>, ) -> Result<Uint<256, 4>, <Arc<T> as State>::Error>

Get storage value of address at index.
§

impl<T> StateRef for Arc<T>
where T: StateRef + ?Sized,

§

type Error = <T as StateRef>::Error

§

fn basic( &self, address: Address, ) -> Result<Option<AccountInfo>, <Arc<T> as StateRef>::Error>

Get basic account information.
§

fn code_by_hash( &self, code_hash: FixedBytes<32>, ) -> Result<Bytecode, <Arc<T> as StateRef>::Error>

Get account code by its hash
§

fn storage( &self, address: Address, index: Uint<256, 4>, ) -> Result<Uint<256, 4>, <Arc<T> as StateRef>::Error>

Get storage value of address at index.
§

impl<S> Strategy for Arc<S>
where S: Strategy + ?Sized,

§

type Tree = <S as Strategy>::Tree

The value tree generated by this Strategy.
§

type Value = <S as Strategy>::Value

The type of value used by functions under test generated by this Strategy. Read more
§

fn new_tree( &self, runner: &mut TestRunner, ) -> Result<<Arc<S> as Strategy>::Tree, Reason>

Generate a new value tree from the given runner. Read more
§

fn prop_map<O, F>(self, fun: F) -> Map<Self, F>
where O: Debug, F: Fn(Self::Value) -> O, Self: Sized,

Returns a strategy which produces values transformed by the function fun. Read more
§

fn prop_map_into<O>(self) -> MapInto<Self, O>
where O: Debug, Self: Sized, Self::Value: Into<O>,

Returns a strategy which produces values of type O by transforming Self with Into<O>. Read more
§

fn prop_perturb<O, F>(self, fun: F) -> Perturb<Self, F>
where O: Debug, F: Fn(Self::Value, TestRng) -> O, Self: Sized,

Returns a strategy which produces values transformed by the function fun, which is additionally given a random number generator. Read more
§

fn prop_flat_map<S, F>(self, fun: F) -> Flatten<Map<Self, F>>
where S: Strategy, F: Fn(Self::Value) -> S, Self: Sized,

Maps values produced by this strategy into new strategies and picks values from those strategies. Read more
§

fn prop_ind_flat_map<S, F>(self, fun: F) -> IndFlatten<Map<Self, F>>
where S: Strategy, F: Fn(Self::Value) -> S, Self: Sized,

Maps values produced by this strategy into new strategies and picks values from those strategies while considering the new strategies to be independent. Read more
§

fn prop_ind_flat_map2<S, F>(self, fun: F) -> IndFlattenMap<Self, F>
where S: Strategy, F: Fn(Self::Value) -> S, Self: Sized,

Similar to prop_ind_flat_map(), but produces 2-tuples with the input generated from self in slot 0 and the derived strategy in slot 1. Read more
§

fn prop_filter<R, F>(self, whence: R, fun: F) -> Filter<Self, F>
where R: Into<Reason>, F: Fn(&Self::Value) -> bool, Self: Sized,

Returns a strategy which only produces values accepted by fun. Read more
§

fn prop_filter_map<F, O>( self, whence: impl Into<Reason>, fun: F, ) -> FilterMap<Self, F>
where F: Fn(Self::Value) -> Option<O>, O: Debug, Self: Sized,

Returns a strategy which only produces transformed values where fun returns Some(value) and rejects those where fun returns None. Read more
§

fn prop_union(self, other: Self) -> Union<Self>
where Self: Sized,

Returns a strategy which picks uniformly from self and other. Read more
§

fn prop_recursive<R, F>( self, depth: u32, desired_size: u32, expected_branch_size: u32, recurse: F, ) -> Recursive<Self::Value, F>
where R: Strategy<Value = Self::Value> + 'static, F: Fn(BoxedStrategy<Self::Value>) -> R, Self: Sized + 'static,

Generate a recursive structure with self items as leaves. Read more
§

fn prop_shuffle(self) -> Shuffle<Self>
where Self: Sized, Self::Value: Shuffleable,

Shuffle the contents of the values produced by this strategy. Read more
§

fn boxed(self) -> BoxedStrategy<Self::Value>
where Self: Sized + 'static,

Erases the type of this Strategy so it can be passed around as a simple trait object. Read more
§

fn sboxed(self) -> SBoxedStrategy<Self::Value>
where Self: Sized + Send + Sync + 'static,

Erases the type of this Strategy so it can be passed around as a simple trait object. Read more
§

fn no_shrink(self) -> NoShrink<Self>
where Self: Sized,

Wraps this strategy to prevent values from being subject to shrinking. Read more
§

impl<S> Subscriber for Arc<S>
where S: Subscriber + ?Sized,

§

fn register_callsite(&self, metadata: &'static Metadata<'static>) -> Interest

Registers a new callsite with this subscriber, returning whether or not the subscriber is interested in being notified about the callsite. Read more
§

fn enabled(&self, metadata: &Metadata<'_>) -> bool

Returns true if a span or event with the specified metadata would be recorded. Read more
§

fn max_level_hint(&self) -> Option<LevelFilter>

Returns the highest verbosity level that this Subscriber will enable, or None, if the subscriber does not implement level-based filtering or chooses not to implement this method. Read more
§

fn new_span(&self, span: &Attributes<'_>) -> Id

Visit the construction of a new span, returning a new span ID for the span being constructed. Read more
§

fn record(&self, span: &Id, values: &Record<'_>)

Record a set of values on a span. Read more
§

fn record_follows_from(&self, span: &Id, follows: &Id)

Adds an indication that span follows from the span with the id follows. Read more
§

fn event_enabled(&self, event: &Event<'_>) -> bool

Determine if an [Event] should be recorded. Read more
§

fn event(&self, event: &Event<'_>)

Records that an Event has occurred. Read more
§

fn enter(&self, span: &Id)

Records that a span has been entered. Read more
§

fn exit(&self, span: &Id)

Records that a span has been exited. Read more
§

fn clone_span(&self, id: &Id) -> Id

Notifies the subscriber that a span ID has been cloned. Read more
§

fn try_close(&self, id: Id) -> bool

Notifies the subscriber that a span ID has been dropped, and returns true if there are now 0 IDs that refer to that span. Read more
§

fn drop_span(&self, id: Id)

👎Deprecated since 0.1.2: use Subscriber::try_close instead
This method is deprecated. Read more
§

fn current_span(&self) -> Current

Returns a type representing this subscriber’s view of the current span. Read more
§

unsafe fn downcast_raw(&self, id: TypeId) -> Option<*const ()>

If self is the same type as the provided TypeId, returns an untyped *const pointer to that type. Otherwise, returns None. Read more
§

fn on_register_dispatch(&self, subscriber: &Dispatch)

Invoked when this subscriber becomes a [Dispatch]. Read more
Source§

impl<T> ToValue for Arc<T>
where T: ToValue + ?Sized,

Source§

fn to_value(&self) -> Value<'_>

Perform the conversion.
§

impl<T> Transaction for Arc<T>
where T: Transaction + ?Sized, Arc<T>: Typed2718 + Debug + Any + Send + Sync + 'static,

§

fn chain_id(&self) -> Option<u64>

Get chain_id.
§

fn nonce(&self) -> u64

Get nonce.
§

fn gas_limit(&self) -> u64

Get gas_limit.
§

fn gas_price(&self) -> Option<u128>

Get gas_price.
§

fn max_fee_per_gas(&self) -> u128

For dynamic fee transactions returns the maximum fee per gas the caller is willing to pay. Read more
§

fn max_priority_fee_per_gas(&self) -> Option<u128>

For dynamic fee transactions returns the Priority fee the caller is paying to the block author. Read more
§

fn max_fee_per_blob_gas(&self) -> Option<u128>

Max fee per blob gas for EIP-4844 transaction. Read more
§

fn priority_fee_or_price(&self) -> u128

Return the max priority fee per gas if the transaction is an dynamic fee transaction, and otherwise return the gas price. Read more
§

fn effective_gas_price(&self, base_fee: Option<u64>) -> u128

Returns the effective gas price for the given base fee. Read more
§

fn effective_tip_per_gas(&self, base_fee: u64) -> Option<u128>

Returns the effective tip for this transaction. Read more
§

fn is_dynamic_fee(&self) -> bool

Returns true if the transaction supports dynamic fees.
§

fn kind(&self) -> TxKind

Returns the transaction kind.
§

fn is_create(&self) -> bool

Returns true if the transaction is a contract creation. We don’t provide a default implementation via kind as it copies the 21-byte [TxKind] for this simple check. A proper implementation shouldn’t allocate.
§

fn to(&self) -> Option<Address>

Get the transaction’s address of the contract that will be called, or the address that will receive the transfer. Read more
§

fn value(&self) -> Uint<256, 4>

Get value.
§

fn input(&self) -> &Bytes

Get data.
§

fn function_selector(&self) -> Option<&FixedBytes<4>>

Returns the first 4bytes of the calldata for a function call. Read more
§

fn access_list(&self) -> Option<&AccessList>

Returns the EIP-2930 access_list for the particular transaction type. Returns None for older transaction types.
§

fn blob_versioned_hashes(&self) -> Option<&[FixedBytes<32>]>

Blob versioned hashes for eip4844 transaction. For previous transaction types this is None.
§

fn blob_count(&self) -> Option<u64>

Returns the number of blobs of this transaction. Read more
§

fn blob_gas_used(&self) -> Option<u64>

Returns the total gas for all blobs in this transaction. Read more
§

fn authorization_list(&self) -> Option<&[SignedAuthorization]>

Returns the [SignedAuthorization] list of the transaction. Read more
§

fn authorization_count(&self) -> Option<u64>

Returns the number of blobs of [SignedAuthorization] in this transactions Read more
§

impl<T> TxReceipt for Arc<T>
where T: TxReceipt + ?Sized, Arc<T>: Clone + Debug + PartialEq + Eq + Send + Sync,

§

type Log = <T as TxReceipt>::Log

The associated log type.
§

fn status_or_post_state(&self) -> Eip658Value

Returns the status or post state of the transaction. Read more
§

fn status(&self) -> bool

Returns true if the transaction was successful OR if the transaction is pre-EIP-658. Results for transactions before EIP-658 are not reliable. Read more
§

fn bloom(&self) -> Bloom

Returns the bloom filter for the logs in the receipt. This operation may be expensive.
§

fn bloom_cheap(&self) -> Option<Bloom>

Returns the bloom filter for the logs in the receipt, if it is cheap to compute.
§

fn cumulative_gas_used(&self) -> u64

Returns the cumulative gas used in the block after this transaction was executed.
§

fn logs(&self) -> &[<Arc<T> as TxReceipt>::Log]

Returns the logs emitted by this transaction.
§

fn with_bloom_ref(&self) -> ReceiptWithBloom<&Self>

Returns [ReceiptWithBloom] with the computed bloom filter [Self::bloom] and a reference to the receipt.
§

fn into_with_bloom(self) -> ReceiptWithBloom<Self>

Consumes the type and converts it into [ReceiptWithBloom] with the computed bloom filter [Self::bloom] and the receipt.
§

impl<Signature, T> TxSigner<Signature> for Arc<T>
where T: TxSigner<Signature> + ?Sized,

§

fn address(&self) -> Address

Get the address of the signer.
§

fn sign_transaction<'life0, 'life1, 'async_trait>( &'life0 self, tx: &'life1 mut (dyn SignableTransaction<Signature> + 'static), ) -> Pin<Box<dyn Future<Output = Result<Signature, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Arc<T>: 'async_trait,

Asynchronously sign an unsigned transaction.
§

impl<Signature, T> TxSignerSync<Signature> for Arc<T>
where T: TxSignerSync<Signature> + ?Sized,

§

fn address(&self) -> Address

Get the address of the signer.
§

fn sign_transaction_sync( &self, tx: &mut (dyn SignableTransaction<Signature> + 'static), ) -> Result<Signature, Error>

Synchronously sign an unsigned transaction.
§

impl<T> ValueParserFactory for Arc<T>
where T: ValueParserFactory + Send + Sync + Clone, <T as ValueParserFactory>::Parser: TypedValueParser<Value = T>,

§

type Parser = MapValueParser<<T as ValueParserFactory>::Parser, fn(_: T) -> Arc<T>>

Generated parser, usually [ValueParser]. Read more
§

fn value_parser() -> <Arc<T> as ValueParserFactory>::Parser

Create the specified [Self::Parser]
§

impl<'a, T> Writeable for Arc<T>
where T: Writeable + ?Sized,

§

fn write_to<W>(&self, sink: &mut W) -> Result<(), Error>
where W: Write + ?Sized,

Writes a string to the given sink. Errors from the sink are bubbled up. The default implementation delegates to write_to_parts, and discards any Part annotations.
§

fn write_to_parts<W>(&self, sink: &mut W) -> Result<(), Error>
where W: PartsWrite + ?Sized,

Write bytes and Part annotations to the given sink. Errors from the sink are bubbled up. The default implementation delegates to write_to, and doesn’t produce any Part annotations.
§

fn writeable_length_hint(&self) -> LengthHint

Returns a hint for the number of UTF-8 bytes that will be written to the sink. Read more
§

fn write_to_string(&self) -> Cow<'_, str>

Creates a new String with the data from this Writeable. Like ToString, but smaller and faster. Read more
§

fn writeable_cmp_bytes(&self, other: &[u8]) -> Ordering

Compares the contents of this Writeable to the given bytes without allocating a String to hold the Writeable contents. Read more
§

impl<T> CartablePointerLike for Arc<T>

§

impl<T> CloneStableDeref for Arc<T>
where T: ?Sized,

§

impl<T> CloneableCart for Arc<T>
where T: ?Sized,

§

impl<T> CloneableCartablePointerLike for Arc<T>

Source§

impl<T, U, A> CoerceUnsized<Arc<U, A>> for Arc<T, A>
where T: Unsize<U> + ?Sized, A: Allocator, U: ?Sized,

Source§

impl<T, A> DerefPure for Arc<T, A>
where A: Allocator, T: ?Sized,

Source§

impl<T, U> DispatchFromDyn<Arc<U>> for Arc<T>
where T: Unsize<U> + ?Sized, U: ?Sized,

1.0.0 · Source§

impl<T, A> Eq for Arc<T, A>
where T: Eq + ?Sized, A: Allocator,

§

impl<T> LifetimeFree for Arc<T>
where T: LifetimeFree,

Source§

impl<T, A> PinCoerceUnsized for Arc<T, A>
where A: Allocator, T: ?Sized,

1.0.0 · Source§

impl<T, A> Send for Arc<T, A>
where T: Sync + Send + ?Sized, A: Allocator + Send,

§

impl<T> StableDeref for Arc<T>
where T: ?Sized,

1.0.0 · Source§

impl<T, A> Sync for Arc<T, A>
where T: Sync + Send + ?Sized, A: Allocator + Sync,

1.33.0 · Source§

impl<T, A> Unpin for Arc<T, A>
where A: Allocator, T: ?Sized,

1.9.0 · Source§

impl<T, A> UnwindSafe for Arc<T, A>

Source§

impl<T, A> UseCloned for Arc<T, A>
where A: Allocator + Clone, T: ?Sized,