referrerpolicy=no-referrer-when-downgrade
substrate_relay_helper::finality::source

Type Alias RequiredHeaderNumberRef

Source
pub type RequiredHeaderNumberRef<C> = Arc<Mutex<<C as Chain>::BlockNumber>>;
Expand description

Shared updatable reference to the maximal header number that we want to sync from the source.

Aliased Type§

struct RequiredHeaderNumberRef<C> { /* private fields */ }

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 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 the associated Arc instance must be valid (i.e. the strong count must be at least 1) for the duration of this method.

§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 the associated Arc instance must be valid (i.e. the strong count must be at least 1) when invoking this method. 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 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, 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().into();
    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 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
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.
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.
§

impl<Block, T> CallApiAt<Block> for Arc<T>
where Block: Block, T: CallApiAt<Block>,

§

type StateBackend = <T as CallApiAt<Block>>::StateBackend

The state backend that is used to store the block states.
§

fn call_api_at( &self, params: CallApiAtParams<'_, Block>, ) -> Result<Vec<u8>, ApiError>

Calls the given api function with the given encoded arguments at the given block and returns the encoded result.
§

fn runtime_version_at( &self, at_hash: <Block as Block>::Hash, ) -> Result<RuntimeVersion, ApiError>

Returns the runtime version at the given block.
§

fn state_at( &self, at: <Block as Block>::Hash, ) -> Result<<Arc<T> as CallApiAt<Block>>::StateBackend, ApiError>

Get the state at the given block.
§

fn initialize_extensions( &self, at: <Block as Block>::Hash, extensions: &mut Extensions, ) -> Result<(), ApiError>

Initialize the extensions for the given block at by using the global extensions factory.
§

impl<T> CanonicalDeserialize for Arc<T>
where T: CanonicalDeserialize + ToOwned + Sync + Send,

§

fn deserialize_with_mode<R>( reader: R, compress: Compress, validate: Validate, ) -> Result<Arc<T>, SerializationError>
where R: Read,

The general deserialize method that takes in customization flags.
§

fn deserialize_compressed<R>(reader: R) -> Result<Self, SerializationError>
where R: Read,

§

fn deserialize_compressed_unchecked<R>( reader: R, ) -> Result<Self, SerializationError>
where R: Read,

§

fn deserialize_uncompressed<R>(reader: R) -> Result<Self, SerializationError>
where R: Read,

§

fn deserialize_uncompressed_unchecked<R>( reader: R, ) -> Result<Self, SerializationError>
where R: Read,

§

impl<T> CanonicalSerialize for Arc<T>
where T: CanonicalSerialize + ToOwned,

§

fn serialize_with_mode<W>( &self, writer: W, compress: Compress, ) -> Result<(), SerializationError>
where W: Write,

The general serialize method that takes in customization flags.
§

fn serialized_size(&self, compress: Compress) -> usize

§

fn serialize_compressed<W>(&self, writer: W) -> Result<(), SerializationError>
where W: Write,

§

fn compressed_size(&self) -> usize

§

fn serialize_uncompressed<W>(&self, writer: W) -> Result<(), SerializationError>
where W: Write,

§

fn uncompressed_size(&self) -> usize

§

impl<T, B> Chain<B> for Arc<T>
where T: Chain<B>, B: Block,

§

fn block_status( &self, hash: <B as Block>::Hash, ) -> Result<BlockStatus, Box<dyn Error + Send>>

Retrieve the status of the block denoted by the given [Block::Hash].
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<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
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
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
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> GetNativeVersion for Arc<T>
where T: GetNativeVersion,

§

fn native_version(&self) -> &NativeVersion

Returns the version of the native runtime.
§

impl<T, Block> GetRuntimeVersionAt<Block> for Arc<T>
where T: GetRuntimeVersionAt<Block>, Block: Block,

§

fn runtime_version( &self, at: <Block as Block>::Hash, ) -> Result<RuntimeVersion, String>

Returns the version of runtime at the given block.
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 json_schema(gen: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
§

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

§

fn sr25519_public_keys( &self, key_type: KeyTypeId, ) -> Vec<CryptoBytes<sp_core::::sr25519::Public::{constant#0}, Sr25519PublicTag>>

Returns all the sr25519 public keys for the given key type.
§

fn sr25519_generate_new( &self, key_type: KeyTypeId, seed: Option<&str>, ) -> Result<CryptoBytes<sp_core::::sr25519::Public::{constant#0}, Sr25519PublicTag>, Error>

Generate a new sr25519 key pair for the given key type and an optional seed. Read more
§

fn sr25519_sign( &self, key_type: KeyTypeId, public: &CryptoBytes<sp_core::::sr25519::Public::{constant#0}, Sr25519PublicTag>, msg: &[u8], ) -> Result<Option<CryptoBytes<sp_core::::sr25519::Signature::{constant#0}, (SignatureTag, Sr25519Tag)>>, Error>

Generate an sr25519 signature for a given message. Read more
§

fn sr25519_vrf_sign( &self, key_type: KeyTypeId, public: &CryptoBytes<sp_core::::sr25519::Public::{constant#0}, Sr25519PublicTag>, data: &VrfSignData, ) -> Result<Option<VrfSignature>, Error>

Generate an sr25519 VRF signature for the given data. Read more
§

fn sr25519_vrf_pre_output( &self, key_type: KeyTypeId, public: &CryptoBytes<sp_core::::sr25519::Public::{constant#0}, Sr25519PublicTag>, input: &VrfTranscript, ) -> Result<Option<VrfPreOutput>, Error>

Generate an sr25519 VRF pre-output for a given input data. Read more
§

fn ed25519_public_keys( &self, key_type: KeyTypeId, ) -> Vec<CryptoBytes<sp_core::::ed25519::Public::{constant#0}, (PublicTag, Ed25519Tag)>>

Returns all ed25519 public keys for the given key type.
§

fn ed25519_generate_new( &self, key_type: KeyTypeId, seed: Option<&str>, ) -> Result<CryptoBytes<sp_core::::ed25519::Public::{constant#0}, (PublicTag, Ed25519Tag)>, Error>

Generate a new ed25519 key pair for the given key type and an optional seed. Read more
§

fn ed25519_sign( &self, key_type: KeyTypeId, public: &CryptoBytes<sp_core::::ed25519::Public::{constant#0}, (PublicTag, Ed25519Tag)>, msg: &[u8], ) -> Result<Option<CryptoBytes<sp_core::::ed25519::Signature::{constant#0}, (SignatureTag, Ed25519Tag)>>, Error>

Generate an ed25519 signature for a given message. Read more
§

fn ecdsa_public_keys( &self, key_type: KeyTypeId, ) -> Vec<CryptoBytes<sp_core::::ecdsa::Public::{constant#0}, (PublicTag, EcdsaTag)>>

Returns all ecdsa public keys for the given key type.
§

fn ecdsa_generate_new( &self, key_type: KeyTypeId, seed: Option<&str>, ) -> Result<CryptoBytes<sp_core::::ecdsa::Public::{constant#0}, (PublicTag, EcdsaTag)>, Error>

Generate a new ecdsa key pair for the given key type and an optional seed. Read more
§

fn ecdsa_sign( &self, key_type: KeyTypeId, public: &CryptoBytes<sp_core::::ecdsa::Public::{constant#0}, (PublicTag, EcdsaTag)>, msg: &[u8], ) -> Result<Option<CryptoBytes<sp_core::::ecdsa::Signature::{constant#0}, (SignatureTag, EcdsaTag)>>, Error>

Generate an ecdsa signature for a given message. Read more
§

fn ecdsa_sign_prehashed( &self, key_type: KeyTypeId, public: &CryptoBytes<sp_core::::ecdsa::Public::{constant#0}, (PublicTag, EcdsaTag)>, msg: &[u8; 32], ) -> Result<Option<CryptoBytes<sp_core::::ecdsa::Signature::{constant#0}, (SignatureTag, EcdsaTag)>>, Error>

Generate an ecdsa signature for a given pre-hashed message. Read more
§

fn bandersnatch_public_keys( &self, key_type: KeyTypeId, ) -> Vec<CryptoBytes<sp_core::::bandersnatch::Public::{constant#0}, (PublicTag, BandersnatchTag)>>

Returns all the bandersnatch public keys for the given key type.
§

fn bandersnatch_generate_new( &self, key_type: KeyTypeId, seed: Option<&str>, ) -> Result<CryptoBytes<sp_core::::bandersnatch::Public::{constant#0}, (PublicTag, BandersnatchTag)>, Error>

Generate a new bandersnatch key pair for the given key type and an optional seed. Read more
§

fn bandersnatch_sign( &self, key_type: KeyTypeId, public: &CryptoBytes<sp_core::::bandersnatch::Public::{constant#0}, (PublicTag, BandersnatchTag)>, msg: &[u8], ) -> Result<Option<CryptoBytes<sp_core::::bandersnatch::Signature::{constant#0}, (SignatureTag, BandersnatchTag)>>, Error>

Generate an bandersnatch signature for a given message. Read more
§

fn bandersnatch_vrf_sign( &self, key_type: KeyTypeId, public: &CryptoBytes<sp_core::::bandersnatch::Public::{constant#0}, (PublicTag, BandersnatchTag)>, input: &VrfSignData, ) -> Result<Option<VrfSignature>, Error>

Generate a bandersnatch VRF signature for the given data. Read more
§

fn bandersnatch_vrf_pre_output( &self, key_type: KeyTypeId, public: &CryptoBytes<sp_core::::bandersnatch::Public::{constant#0}, (PublicTag, BandersnatchTag)>, input: &VrfInput, ) -> Result<Option<VrfPreOutput>, Error>

Generate a bandersnatch VRF pre-output for a given input data. Read more
§

fn bandersnatch_ring_vrf_sign( &self, key_type: KeyTypeId, public: &CryptoBytes<sp_core::::bandersnatch::Public::{constant#0}, (PublicTag, BandersnatchTag)>, input: &VrfSignData, prover: &RingProver<Fp<MontBackend<FrConfig, 4>, 4>, KZG<Bls12<Config<HostHooks>>>, BandersnatchConfig<HostHooks>>, ) -> Result<Option<RingVrfSignature>, Error>

Generate a bandersnatch ring-VRF signature for the given data. Read more
§

fn bls381_public_keys( &self, id: KeyTypeId, ) -> Vec<CryptoBytes<sp_core::::bls::Public::{constant#0}, (PublicTag, (BlsTag, TinyBLS<Bls12<Config>, Config>))>>

Returns all bls12-381 public keys for the given key type.
§

fn ecdsa_bls381_public_keys( &self, id: KeyTypeId, ) -> Vec<CryptoBytes<sp_core::::paired_crypto::ecdsa_bls381::Public::{constant#0}, (PublicTag, (PairedCryptoTag, EcdsaBls381Tag))>>

Returns all (ecdsa,bls12-381) paired public keys for the given key type.
§

fn bls381_generate_new( &self, key_type: KeyTypeId, seed: Option<&str>, ) -> Result<CryptoBytes<sp_core::::bls::Public::{constant#0}, (PublicTag, (BlsTag, TinyBLS<Bls12<Config>, Config>))>, Error>

Generate a new bls381 key pair for the given key type and an optional seed. Read more
§

fn ecdsa_bls381_generate_new( &self, key_type: KeyTypeId, seed: Option<&str>, ) -> Result<CryptoBytes<sp_core::::paired_crypto::ecdsa_bls381::Public::{constant#0}, (PublicTag, (PairedCryptoTag, EcdsaBls381Tag))>, Error>

Generate a new (ecdsa,bls381) key pair for the given key type and an optional seed. Read more
§

fn bls381_sign( &self, key_type: KeyTypeId, public: &CryptoBytes<sp_core::::bls::Public::{constant#0}, (PublicTag, (BlsTag, TinyBLS<Bls12<Config>, Config>))>, msg: &[u8], ) -> Result<Option<CryptoBytes<sp_core::::bls::Signature::{constant#0}, (SignatureTag, (BlsTag, TinyBLS<Bls12<Config>, Config>))>>, Error>

Generate a bls381 signature for a given message. Read more
§

fn ecdsa_bls381_sign( &self, key_type: KeyTypeId, public: &CryptoBytes<sp_core::::paired_crypto::ecdsa_bls381::Public::{constant#0}, (PublicTag, (PairedCryptoTag, EcdsaBls381Tag))>, msg: &[u8], ) -> Result<Option<CryptoBytes<sp_core::::paired_crypto::ecdsa_bls381::Signature::{constant#0}, (SignatureTag, (PairedCryptoTag, EcdsaBls381Tag))>>, Error>

Generate a (ecdsa,bls381) signature pair for a given message. Read more
§

fn ecdsa_bls381_sign_with_keccak256( &self, key_type: KeyTypeId, public: &CryptoBytes<sp_core::::paired_crypto::ecdsa_bls381::Public::{constant#0}, (PublicTag, (PairedCryptoTag, EcdsaBls381Tag))>, msg: &[u8], ) -> Result<Option<CryptoBytes<sp_core::::paired_crypto::ecdsa_bls381::Signature::{constant#0}, (SignatureTag, (PairedCryptoTag, EcdsaBls381Tag))>>, Error>

Hashes the message using keccak256 and then signs it using ECDSA algorithm. It does not affect the behavior of BLS12-381 component. It generates BLS12-381 Signature according to IETF standard. Read more
§

fn insert( &self, key_type: KeyTypeId, suri: &str, public: &[u8], ) -> Result<(), ()>

Insert a new secret key.
§

fn keys(&self, key_type: KeyTypeId) -> Result<Vec<Vec<u8>>, Error>

List all supported keys of a given type. Read more
§

fn has_keys(&self, public_keys: &[(Vec<u8>, KeyTypeId)]) -> bool

Checks if the private keys for the given public key and key type combinations exist. Read more
§

fn sign_with( &self, id: KeyTypeId, crypto_id: CryptoTypeId, public: &[u8], msg: &[u8], ) -> Result<Option<Vec<u8>>, Error>

Convenience method to sign a message using the given key type and a raw public key for secret lookup. Read more
Source§

impl<L, S> Layer<S> for Arc<L>
where L: Layer<S>, S: Subscriber,

Source§

fn on_layer(&mut self, subscriber: &mut S)

Performs late initialization when attaching a Layer to a [Subscriber]. Read more
Source§

fn new_span(&self, attrs: &Attributes<'_>, id: &Id, ctx: Context<'_, S>)

Notifies this layer that a new span was constructed with the given Attributes and Id.
Source§

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

Registers a new callsite with this layer, returning whether or not the layer is interested in being notified about the callsite, similarly to Subscriber::register_callsite. Read more
Source§

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

Returns true if this layer is interested in a span or event with the given metadata in the current Context, similarly to Subscriber::enabled. Read more
Source§

fn on_record(&self, span: &Id, values: &Record<'_>, ctx: Context<'_, S>)

Notifies this layer that a span with the given Id recorded the given values.
Source§

fn on_follows_from(&self, span: &Id, follows: &Id, ctx: Context<'_, S>)

Notifies this layer that a span with the ID span recorded that it follows from the span with the ID follows.
Source§

fn on_event(&self, event: &Event<'_>, ctx: Context<'_, S>)

Notifies this layer that an event has occurred.
Source§

fn on_enter(&self, id: &Id, ctx: Context<'_, S>)

Notifies this layer that a span with the given ID was entered.
Source§

fn on_exit(&self, id: &Id, ctx: Context<'_, S>)

Notifies this layer that the span with the given ID was exited.
Source§

fn on_close(&self, id: Id, ctx: Context<'_, S>)

Notifies this layer that the span with the given ID has been closed.
Source§

fn on_id_change(&self, old: &Id, new: &Id, ctx: Context<'_, S>)

Notifies this layer that a span ID has been cloned, and that the subscriber returned a different ID.
Source§

fn and_then<L>(self, layer: L) -> Layered<L, Self, S>
where L: Layer<S>, Self: Sized,

Composes this layer around the given Layer, returning a Layered struct implementing Layer. Read more
Source§

fn with_subscriber(self, inner: S) -> Layered<Self, S>
where Self: Sized,

Composes this Layer with the given Subscriber, returning a Layered struct that implements Subscriber. Read more
Source§

fn with_filter<F>(self, filter: F) -> Filtered<Self, F, S>
where Self: Sized, F: Filter<S>,

Combines self with a Filter, returning a Filtered layer. 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
§

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

§

type Block = <T as LocalTransactionPool>::Block

Block type.
§

type Hash = <T as LocalTransactionPool>::Hash

Transaction hash type.
§

type Error = <T as LocalTransactionPool>::Error

Error type.
§

fn submit_local( &self, at: <<Arc<T> as LocalTransactionPool>::Block as Block>::Hash, xt: <<Arc<T> as LocalTransactionPool>::Block as Block>::Extrinsic, ) -> Result<<Arc<T> as LocalTransactionPool>::Hash, <Arc<T> as LocalTransactionPool>::Error>

Submits the given local unverified transaction to the pool blocking the current thread for any necessary pre-verification. NOTE: It MUST NOT be used for transactions that originate from the network or RPC, since the validation is performed with TransactionSource::Local.
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
Source§

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

Source§

type Writer = ArcWriter<W>

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

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

Returns an instance of Writer. Read more
Source§

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

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

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

§

fn max_encoded_len() -> usize

Upper bound, in bytes, of the maximum encoded size of this item.
§

impl<T, BlockHash, BlockNumber> NetworkBlock<BlockHash, BlockNumber> for Arc<T>
where T: NetworkBlock<BlockHash, BlockNumber> + ?Sized,

§

fn announce_block(&self, hash: BlockHash, data: Option<Vec<u8>>)

Make sure an important block is propagated to peers. Read more
§

fn new_best_block_imported(&self, hash: BlockHash, number: BlockNumber)

Inform the network service about new best imported block.
§

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

§

fn get_value(&self, key: &Key)

Start getting a value from the DHT.
§

fn put_value(&self, key: Key, value: Vec<u8>)

Start putting a value in the DHT.
§

fn put_record_to( &self, record: Record, peers: HashSet<PeerId>, update_local_storage: bool, )

Start putting the record to peers. Read more
§

fn store_record( &self, key: Key, value: Vec<u8>, publisher: Option<PeerId>, expires: Option<Instant>, )

Store a record in the DHT memory store.
§

fn start_providing(&self, key: Key)

Register this node as a provider for key on the DHT.
§

fn stop_providing(&self, key: Key)

Deregister this node as a provider for key on the DHT.
§

fn get_providers(&self, key: Key)

Start getting the list of providers for key on the DHT.
§

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

§

fn event_stream( &self, name: &'static str, ) -> Pin<Box<dyn Stream<Item = Event> + Send>>

Returns a stream containing the events that happen on the network. Read more
§

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

§

fn set_authorized_peers(&self, peers: HashSet<PeerId>)

Set authorized peers. Read more
§

fn set_authorized_only(&self, reserved_only: bool)

Set authorized_only flag. Read more
§

fn add_known_address(&self, peer_id: PeerId, addr: Multiaddr)

Adds an address known to a node.
§

fn report_peer(&self, peer_id: PeerId, cost_benefit: ReputationChange)

Report a given peer as either beneficial (+) or costly (-) according to the given scalar.
§

fn peer_reputation(&self, peer_id: &PeerId) -> i32

Get peer reputation.
§

fn disconnect_peer(&self, peer_id: PeerId, protocol: ProtocolName)

Disconnect from a node as soon as possible. Read more
§

fn accept_unreserved_peers(&self)

Connect to unreserved peers and allow unreserved peers to connect for syncing purposes.
§

fn deny_unreserved_peers(&self)

Disconnect from unreserved peers and deny new unreserved peers to connect for syncing purposes.
§

fn add_reserved_peer(&self, peer: MultiaddrWithPeerId) -> Result<(), String>

Adds a PeerId and its Multiaddr as reserved for a sync protocol (default peer set). Read more
§

fn remove_reserved_peer(&self, peer_id: PeerId)

Removes a PeerId from the list of reserved peers for a sync protocol (default peer set).
§

fn set_reserved_peers( &self, protocol: ProtocolName, peers: HashSet<Multiaddr>, ) -> Result<(), String>

Sets the reserved set of a protocol to the given set of peers. Read more
§

fn add_peers_to_reserved_set( &self, protocol: ProtocolName, peers: HashSet<Multiaddr>, ) -> Result<(), String>

Add peers to a peer set. Read more
§

fn remove_peers_from_reserved_set( &self, protocol: ProtocolName, peers: Vec<PeerId>, ) -> Result<(), String>

Remove peers from a peer set. Read more
§

fn sync_num_connected(&self) -> usize

Returns the number of peers in the sync peer set we’re connected to.
§

fn peer_role(&self, peer_id: PeerId, handshake: Vec<u8>) -> Option<ObservedRole>

Attempt to get peer role. Read more
§

fn reserved_peers<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<PeerId>, ()>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Get the list of reserved peers. Read more
§

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

§

fn request<'life0, 'async_trait>( &'life0 self, target: PeerId, protocol: ProtocolName, request: Vec<u8>, fallback_request: Option<(Vec<u8>, ProtocolName)>, connect: IfDisconnected, ) -> Pin<Box<dyn Future<Output = Result<(Vec<u8>, ProtocolName), RequestFailure>> + Send + 'async_trait>>
where 'life0: 'async_trait, Arc<T>: 'async_trait,

Sends a single targeted request to a specific peer. On success, returns the response of the peer. Read more
§

fn start_request( &self, target: PeerId, protocol: ProtocolName, request: Vec<u8>, fallback_request: Option<(Vec<u8>, ProtocolName)>, tx: Sender<Result<(Vec<u8>, ProtocolName), RequestFailure>>, connect: IfDisconnected, )

Variation of request which starts a request whose response is delivered on a provided channel. Read more
§

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

§

fn sign_with_local_identity( &self, msg: Vec<u8>, ) -> Result<Signature, SigningError>

Signs the message with the KeyPair that defines the local [PeerId].
§

fn verify( &self, peer_id: PeerId, public_key: &Vec<u8>, signature: &Vec<u8>, message: &Vec<u8>, ) -> Result<bool, String>

Verify signature using peer’s public key. Read more
§

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

§

fn external_addresses(&self) -> Vec<Multiaddr>

Returns the local external addresses.
§

fn listen_addresses(&self) -> Vec<Multiaddr>

Returns the listening addresses (without trailing /p2p/ with our PeerId).
§

fn local_peer_id(&self) -> PeerId

Returns the local Peer ID.
§

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

§

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

High-level network status information. Read more
§

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

Get the network state. Read more
§

impl<T, BlockHash, BlockNumber> NetworkSyncForkRequest<BlockHash, BlockNumber> for Arc<T>
where T: NetworkSyncForkRequest<BlockHash, BlockNumber> + ?Sized,

§

fn set_sync_fork_request( &self, peers: Vec<PeerId>, hash: BlockHash, number: BlockNumber, )

Notifies the sync service to try and sync the given block from the given peers. Read more
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
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
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<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
§

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

§

fn is_major_syncing(&self) -> bool

Whether the synchronization service is undergoing major sync. Returns true if so.
§

fn is_offline(&self) -> bool

Whether the synchronization service is offline. Returns true if so.
§

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

§

type Identity = T

The type identifying for which type info is provided. Read more
§

fn type_info() -> Type

Returns the static type identifier for Self.
§

impl<T> Valid for Arc<T>
where T: Valid + Sync + Send,

§

fn check(&self) -> Result<(), SerializationError>

§

fn batch_check<'a>( batch: impl Iterator<Item = &'a Arc<T>> + Send, ) -> Result<(), SerializationError>
where Arc<T>: 'a,

§

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<T> WasmModuleResources for Arc<T>
where T: WasmModuleResources,

§

type FuncType = <T as WasmModuleResources>::FuncType

The function type used for validation.
§

fn table_at(&self, at: u32) -> Option<TableType>

Returns the table at given index if any.
§

fn memory_at(&self, at: u32) -> Option<MemoryType>

Returns the linear memory at given index.
§

fn tag_at(&self, at: u32) -> Option<&<Arc<T> as WasmModuleResources>::FuncType>

Returns the tag at given index.
§

fn global_at(&self, at: u32) -> Option<GlobalType>

Returns the global variable at given index.
§

fn func_type_at( &self, type_idx: u32, ) -> Option<&<Arc<T> as WasmModuleResources>::FuncType>

Returns the FuncType associated with the given type index.
§

fn type_index_of_function(&self, func_idx: u32) -> Option<u32>

Returns the type index associated with the given function index. type_of_function = func_type_at(type_index_of_function)
§

fn type_of_function( &self, func_idx: u32, ) -> Option<&<Arc<T> as WasmModuleResources>::FuncType>

Returns the FuncType associated with the given function index.
§

fn check_value_type( &self, t: ValType, features: &WasmFeatures, offset: usize, ) -> Result<(), BinaryReaderError>

Check a value type. This requires using func_type_at to check references
§

fn element_type_at(&self, at: u32) -> Option<RefType>

Returns the element type at the given index.
§

fn matches(&self, t1: ValType, t2: ValType) -> bool

Under the function references proposal, returns whether t1 <= t2. Otherwise, returns whether t1 == t2
§

fn element_count(&self) -> u32

Returns the number of elements.
§

fn data_count(&self) -> Option<u32>

Returns the number of bytes in the Wasm data section.
§

fn is_function_referenced(&self, idx: u32) -> bool

Returns whether the function index is referenced in the module anywhere outside of the start/function sections.
§

fn check_heap_type( &self, heap_type: HeapType, features: &WasmFeatures, offset: usize, ) -> Result<(), BinaryReaderError>

Checks that a HeapType is valid, notably its function index if one is used.
§

impl<T> WrapperTypeDecode for Arc<T>

§

type Wrapped = T

A wrapped type.
§

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,

§

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

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,

§

impl<T> EncodeLike<Arc<T>> for T
where T: Encode,

§

impl<T> EncodeLike<T> for Arc<T>
where T: Encode,

§

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

1.0.0 · Source§

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

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>

§

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