Skip to main content

Blockchain

Struct Blockchain 

Source
pub struct Blockchain { /* private fields */ }
Expand description

The blockchain manager for a forked chain.

Blockchain is the main entry point for creating local forks of live Polkadot SDK chains. It manages the fork lifecycle, block building, and provides APIs for querying state and executing runtime calls.

§Creating a Fork

Use Blockchain::fork to create a new fork from a live chain:

let blockchain = Blockchain::fork(&endpoint, None).await?;

§Block Building

Build blocks using build_block or build_empty_block:

// Build a block with user extrinsics
let block = blockchain.build_block(vec![signed_extrinsic]).await?;

// Build an empty block (just inherents)
let block = blockchain.build_empty_block().await?;

§Querying State

Query storage at the current head or at a specific block:

// At head
let value = blockchain.storage(&key).await?;

// At a specific block
let value = blockchain.storage_at(block_hash, &key).await?;

§Thread Safety

Blockchain is Send + Sync and can be safely shared across async tasks. Internal state is protected by RwLock.

Implementations§

Source§

impl Blockchain

Source

pub async fn fork( endpoint: &Url, cache_path: Option<&Path>, ) -> Result<Arc<Self>, BlockchainError>

Create a new blockchain forked from a live chain.

This connects to the live chain, fetches the fork point block, initializes the runtime executor, and detects the chain type.

§Arguments
  • endpoint - RPC endpoint URL of the live chain
  • cache_path - Optional path for persistent SQLite cache. If None, an in-memory cache is used.
§Returns

A new Blockchain instance ready for block building.

§Example
use pop_fork::Blockchain;
use std::path::Path;
use url::Url;

let endpoint: Url = "wss://rpc.polkadot.io".parse()?;

// With in-memory cache
let blockchain = Blockchain::fork(&endpoint, None).await?;

// With persistent cache
let blockchain = Blockchain::fork(&endpoint, Some(Path::new("./cache.sqlite"))).await?;
Source

pub async fn fork_at( endpoint: &Url, cache_path: Option<&Path>, fork_point: Option<BlockForkPoint>, ) -> Result<Arc<Self>, BlockchainError>

Create a new blockchain forked from a live chain at a specific block.

Similar to fork, but allows specifying the exact block to fork from.

§Arguments
  • endpoint - RPC endpoint URL of the live chain
  • cache_path - Optional path for persistent SQLite cache
  • fork_point - Block number or hash to fork from. If None, uses the latest finalized block.
§Example
// Fork at a specific block number
let blockchain = Blockchain::fork_at(&endpoint, None, Some(12345678.into())).await?;

// Fork at a specific block hash
let blockchain = Blockchain::fork_at(&endpoint, None, Some(block_hash.into())).await?;
Source

pub async fn fork_with_config( endpoint: &Url, cache_path: Option<&Path>, fork_point: Option<BlockForkPoint>, executor_config: ExecutorConfig, ) -> Result<Arc<Self>, BlockchainError>

Create a new blockchain forked from a live chain with custom executor configuration.

This is the most flexible fork method, allowing customization of both the fork point and the executor configuration.

§Arguments
  • endpoint - RPC endpoint URL of the live chain
  • cache_path - Optional path for persistent SQLite cache
  • fork_point - Block number or hash to fork from. If None, uses the latest finalized block.
  • executor_config - Configuration for the runtime executor
§Example
use pop_fork::{Blockchain, ExecutorConfig, SignatureMockMode};

// Fork with signature mocking enabled (useful for testing)
let config = ExecutorConfig {
    signature_mock: SignatureMockMode::AlwaysValid,
    ..Default::default()
};
let blockchain = Blockchain::fork_with_config(&endpoint, None, None, config).await?;
Source

pub async fn warmup(self: &Arc<Self>)

Run background warmup to pre-cache expensive resources.

This method is designed to be spawned as a background task immediately after forking. It pre-populates caches that would otherwise cause a cold-start penalty on the first block build:

  1. WASM prototype compilation (~2-5s for large runtimes like Asset Hub). The compiled prototype is stored in warm_prototype for reuse by the first build_block() call.

  2. Storage prefetch (~1-2s). Batch-fetches all StorageValue keys and the first page of each pallet’s storage map, populating the remote cache.

  3. Inherent provider warmup. Calls warmup() on each registered provider (e.g. TimestampInherent caches the slot duration to avoid a separate WASM execution during block building).

If a block is built before warmup finishes, the builder falls back to its normal (non-cached) path. The Mutex/OnceCell guards ensure no races.

Source

pub fn chain_name(&self) -> &str

Get the chain name.

Source

pub fn chain_type(&self) -> &ChainType

Get the chain type.

Source

pub fn fork_point(&self) -> H256

Get the fork point block hash.

Source

pub fn fork_point_number(&self) -> u32

Get the fork point block number.

Source

pub fn endpoint(&self) -> &Url

Get the RPC endpoint URL.

Source

pub async fn genesis_hash(&self) -> Result<String, BlockchainError>

Get the genesis hash, formatted as a hex string with “0x” prefix.

This method lazily fetches and caches the genesis hash on first call. The cache is per-instance, so each forked chain maintains its own value even when multiple forks run in the same process.

§Returns

The genesis hash as “0x” prefixed hex string, or an error if fetching fails.

Source

pub async fn chain_properties(&self) -> Option<Value>

Get the chain properties.

This method lazily fetches and caches the chain properties on first call. The cache is per-instance, so each forked chain maintains its own value even when multiple forks run in the same process.

§Returns

The chain properties as JSON, or None if not available.

Source

pub fn subscribe_events(&self) -> Receiver<BlockchainEvent>

Subscribe to blockchain events.

Returns a receiver that will get events when blocks are built. Use this for implementing reactive RPC subscriptions.

§Example
let mut receiver = blockchain.subscribe_events();
tokio::spawn(async move {
    while let Ok(event) = receiver.recv().await {
        match event {
            BlockchainEvent::NewBlock { hash, number, .. } => {
                println!("New block #{} ({:?})", number, hash);
            }
        }
    }
});
Source

pub async fn head(&self) -> Block

Get the current head block.

Source

pub async fn head_number(&self) -> u32

Get the current head block number.

Source

pub async fn head_hash(&self) -> H256

Get the current head block hash.

Source

pub async fn block_body( &self, hash: H256, ) -> Result<Option<Vec<Vec<u8>>>, BlockchainError>

Get block body (extrinsics) by hash.

This method searches for the block in three places:

  1. The current head block
  2. Locally-built blocks (traversing the parent chain)
  3. The remote chain (for blocks at or before the fork point)
§Arguments
  • hash - The block hash to query
§Returns

The block’s extrinsics as raw bytes, or None if the block is not found.

Source

pub async fn block_header( &self, hash: H256, ) -> Result<Option<Vec<u8>>, BlockchainError>

Get block header by hash.

This method searches for the block in three places:

  1. Locally-built blocks (traversing the parent chain)
  2. The fork point block
  3. The remote chain (for blocks at or before the fork point)
§Arguments
  • hash - The block hash to query
§Returns

The SCALE-encoded block header, or None if the block is not found.

Source

pub async fn block_hash_at( &self, block_number: u32, ) -> Result<Option<H256>, BlockchainError>

Get block hash by block number.

This method searches for the block in three places:

  1. Locally-built blocks (traversing the parent chain from head)
  2. The fork point block
  3. The remote chain (for blocks before the fork point)
§Arguments
  • block_number - The block number to query
§Returns

The block hash, or None if the block number doesn’t exist.

Source

pub async fn block_number_by_hash( &self, hash: H256, ) -> Result<Option<u32>, BlockchainError>

Get block number by block hash.

This method searches for the block in two places:

  1. Locally-built blocks (traversing the parent chain from head)
  2. The remote chain (for blocks at or before the fork point)
§Arguments
  • hash - The block hash to query
§Returns

The block number, or None if the block hash doesn’t exist.

Source

pub async fn block_parent_hash( &self, hash: H256, ) -> Result<Option<H256>, BlockchainError>

Get parent hash of a block by its hash.

This method searches for the block in two places:

  1. Locally-built blocks (traversing the parent chain from head)
  2. The remote chain (for blocks at or before the fork point)
§Arguments
  • hash - The block hash to query
§Returns

The parent block hash, or None if the block hash doesn’t exist.

Source

pub async fn build_block( &self, extrinsics: Vec<Vec<u8>>, ) -> Result<BuildBlockResult, BlockchainError>

Build a new block with the given extrinsics.

This creates a new block on top of the current head, applying:

  1. Inherent extrinsics (timestamp, parachain validation data, etc.)
  2. User-provided extrinsics

The new block becomes the new head.

§Arguments
  • extrinsics - User extrinsics to include in the block
§Returns

A BuildBlockResult containing the newly created block and information about which extrinsics were successfully included vs which failed.

§Example
let extrinsic = /* create signed extrinsic */;
let result = blockchain.build_block(vec![extrinsic]).await?;
println!("New block: #{} ({:?})", result.block.number, result.block.hash);
println!("Included: {}, Failed: {}", result.included.len(), result.failed.len());
Source

pub async fn build_empty_block(&self) -> Result<Block, BlockchainError>

Build an empty block (just inherents, no user extrinsics).

This is useful for advancing the chain state without any user transactions.

§Returns

The newly created block.

Source

pub async fn call( &self, method: &str, args: &[u8], ) -> Result<Vec<u8>, BlockchainError>

Execute a runtime call at the current head.

§Arguments
  • method - Runtime API method name (e.g., “Core_version”)
  • args - SCALE-encoded arguments
§Returns

The SCALE-encoded result from the runtime.

Source

pub async fn storage( &self, key: &[u8], ) -> Result<Option<Vec<u8>>, BlockchainError>

Get storage value at the current head.

§Arguments
  • key - Storage key
§Returns

The storage value, or None if the key doesn’t exist.

Source

pub async fn storage_at( &self, block_number: u32, key: &[u8], ) -> Result<Option<Vec<u8>>, BlockchainError>

Get storage value at a specific block number.

§Arguments
  • block_number - Block number to query at
  • key - Storage key
§Returns

The storage value, or None if the key doesn’t exist.

Source

pub async fn storage_keys_paged( &self, prefix: &[u8], count: u32, start_key: Option<&[u8]>, at: Option<H256>, ) -> Result<Vec<Vec<u8>>, BlockchainError>

Get paginated storage keys matching a prefix at a given block.

If at is None, defaults to the current head block hash so that newly created keys are visible to callers such as polkadot.js.

For fork-local blocks, the full key set is obtained by merging remote keys (at the fork point) with local modifications, then applying pagination. For pre-fork blocks, delegates to the upstream RPC.

Source

pub async fn storage_keys_by_prefix( &self, prefix: &[u8], at: H256, ) -> Result<Vec<Vec<u8>>, BlockchainError>

Get all storage keys matching a prefix, with prefetching. Enumerate all storage keys matching a prefix at a given block.

For pre-fork blocks, delegates to the remote RPC’s get_keys method. For fork-local blocks, merges remote keys (at the fork point) with local modifications so that keys added or deleted after the fork are visible.

at is the block hash whose state should be scanned for keys.

Source

pub async fn call_at_block( &self, hash: H256, method: &str, args: &[u8], ) -> Result<Option<Vec<u8>>, BlockchainError>

Execute a runtime call at a specific block hash.

§Arguments
  • hash - The block hash to execute at
  • method - Runtime API method name (e.g., “Core_version”)
  • args - SCALE-encoded arguments
§Returns
  • Ok(Some(result)) - Call succeeded at the specified block
  • Ok(None) - Block hash not found
  • Err(_) - Call failed (runtime error, storage error, etc.)
Source

pub async fn storage_batch( &self, at: H256, keys: &[&[u8]], ) -> Result<Vec<Option<Vec<u8>>>, BlockchainError>

Batch-fetch storage values from the upstream at a given block.

Uses the remote storage layer’s batch fetch, which checks the cache first and fetches only uncached keys in a single upstream RPC call. This is significantly faster than fetching each key individually.

Automatically reconnects to the upstream if the connection has dropped.

Source

pub async fn proxy_state_call( &self, method: &str, args: &[u8], at: H256, ) -> Result<Vec<u8>, BlockchainError>

Proxy a runtime API call to the upstream RPC endpoint.

This forwards the call to the upstream node at the given block, which has a JIT-compiled runtime and handles computationally expensive calls (like metadata generation) much faster than the local WASM interpreter.

Automatically reconnects if the upstream connection has dropped.

Source

pub async fn validate_extrinsic( &self, extrinsic: &[u8], ) -> Result<ValidTransaction, TransactionValidityError>

Validate an extrinsic before pool submission.

Calls TaggedTransactionQueue_validate_transaction runtime API to check if the extrinsic is valid for inclusion in a future block.

§Arguments
  • extrinsic - The encoded extrinsic to validate
§Returns
  • Ok(ValidTransaction) - Transaction is valid with priority/dependency info
  • Err(TransactionValidityError) - Transaction is invalid or unknown
§Example
match blockchain.validate_extrinsic(&extrinsic_bytes).await {
    Ok(valid) => println!("Valid with priority {}", valid.priority),
    Err(TransactionValidityError::Invalid(inv)) => {
        println!("Invalid: {:?}", inv);
    }
    Err(TransactionValidityError::Unknown(unk)) => {
        println!("Unknown validity: {:?}", unk);
    }
}
Source

pub async fn initialize_dev_accounts(&self) -> Result<(), BlockchainError>

Fund well-known dev accounts and optionally set sudo.

Detects the chain type from the isEthereum chain property:

  • Ethereum chains: funds both Substrate (Alice, Bob, …) and Ethereum (Alith, Baltathar, …) dev accounts for compatibility.
  • Substrate chains: funds Substrate dev accounts only.

For each account:

  • If it already exists on-chain, patches its free balance
  • If it does not exist, creates a fresh AccountInfo

If the chain has a Sudo pallet, sets sudo to a dev account matching the runtime’s account-id width (20-byte or 32-byte), with first-account fallback.

Source

pub async fn clear_local_storage(&self) -> Result<(), CacheError>

Clear all locally tracked storage data from the cache.

This removes all key-value pairs that were created during block building (stored in the local_keys and local_values tables). Remote chain data that was fetched and cached remains intact.

Call this during shutdown to clean up local storage state.

§Returns

Ok(()) on success, or a cache error if the operation fails.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AggregateExpressionMethods for T

Source§

fn aggregate_distinct(self) -> Self::Output
where Self: DistinctDsl,

DISTINCT modifier for aggregate functions Read more
Source§

fn aggregate_all(self) -> Self::Output
where Self: AllDsl,

ALL modifier for aggregate functions Read more
Source§

fn aggregate_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add an aggregate function filter Read more
Source§

fn aggregate_order<O>(self, o: O) -> Self::Output
where Self: OrderAggregateDsl<O>,

Add an aggregate function order Read more
Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CheckedConversion for T

Source§

fn checked_from<T>(t: T) -> Option<Self>
where Self: TryFrom<T>,

Convert from a value of T into an equivalent instance of Option<Self>. Read more
Source§

fn checked_into<T>(self) -> Option<T>
where Self: TryInto<T>,

Consume self to return Some equivalent value of Option<T>. Read more
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<I, T> ExtractContext<I, ()> for T

Source§

fn extract_context(self, _original_input: I)

Given the context attached to a nom error, and given the original input to the nom parser, extract more the useful context information. Read more
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoSql for T

Source§

fn into_sql<T>(self) -> Self::Expression

Convert self to an expression for Diesel’s query builder. Read more
Source§

fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
where &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert &self to an expression for Diesel’s query builder. Read more
Source§

impl<Src, Dest> IntoTuple<Dest> for Src
where Dest: FromTuple<Src>,

Source§

fn into_tuple(self) -> Dest

Source§

impl<T, Outer> IsWrappedBy<Outer> for T
where Outer: AsRef<T> + AsMut<T> + From<T>, T: From<Outer>,

Source§

fn from_ref(outer: &Outer) -> &T

Get a reference to the inner from the outer.

Source§

fn from_mut(outer: &mut Outer) -> &mut T

Get a mutable reference to the inner from the outer.

Source§

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

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<I> RecreateContext<I> for I

Source§

fn recreate_context(_original_input: I, tail: I) -> I

Given the original input, as well as the context reported by nom, recreate a context in the original string where the error occurred. Read more
Source§

impl<T, Conn> RunQueryDsl<Conn> for T

Source§

fn execute<'conn, 'query>( self, conn: &'conn mut Conn, ) -> <Conn as AsyncConnectionCore>::ExecuteFuture<'conn, 'query>
where Conn: AsyncConnectionCore + Send, Self: ExecuteDsl<Conn> + 'query,

Executes the given command, returning the number of rows affected. Read more
Source§

fn load<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
where U: Send, Conn: AsyncConnectionCore, Self: LoadQuery<'query, Conn, U> + 'query,

Executes the given query, returning a Vec with the returned rows. Read more
Source§

fn load_stream<'conn, 'query, U>( self, conn: &'conn mut Conn, ) -> Self::LoadFuture<'conn>
where Conn: AsyncConnectionCore, U: 'conn, Self: LoadQuery<'query, Conn, U> + 'query,

Executes the given query, returning a [Stream] with the returned rows. Read more
Source§

fn get_result<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, LoadNext<Pin<Box<Self::Stream<'conn>>>>>
where U: Send + 'conn, Conn: AsyncConnectionCore, Self: LoadQuery<'query, Conn, U> + 'query,

Runs the command, and returns the affected row. Read more
Source§

fn get_results<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
where U: Send, Conn: AsyncConnectionCore, Self: LoadQuery<'query, Conn, U> + 'query,

Runs the command, returning an Vec with the affected rows. Read more
Source§

fn first<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<<Self::Output as LoadQuery<'query, Conn, U>>::LoadFuture<'conn>, LoadNext<Pin<Box<<Self::Output as LoadQuery<'query, Conn, U>>::Stream<'conn>>>>>
where U: Send + 'conn, Conn: AsyncConnectionCore, Self: LimitDsl, Self::Output: LoadQuery<'query, Conn, U> + Send + 'query,

Attempts to load a single record. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatedConversion for T

Source§

fn saturated_from<T>(t: T) -> Self
where Self: UniqueSaturatedFrom<T>,

Convert from a value of T into an equivalent instance of Self. Read more
Source§

fn saturated_into<T>(self) -> T
where Self: UniqueSaturatedInto<T>,

Consume self to return an equivalent value of T. Read more
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.
Source§

impl<S, T> UncheckedInto<T> for S
where T: UncheckedFrom<S>,

Source§

fn unchecked_into(self) -> T

The counterpart to unchecked_from.
Source§

impl<T, S> UniqueSaturatedInto<T> for S
where T: Bounded, S: TryInto<T>,

Source§

fn unique_saturated_into(self) -> T

Consume self to return an equivalent value of T.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WindowExpressionMethods for T

Source§

fn over(self) -> Self::Output
where Self: OverDsl,

Turn a function call into a window function call Read more
Source§

fn window_filter<P>(self, f: P) -> Self::Output
where P: AsExpression<Bool>, Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,

Add a filter to the current window function Read more
Source§

fn partition_by<E>(self, expr: E) -> Self::Output
where Self: PartitionByDsl<E>,

Add a partition clause to the current window function Read more
Source§

fn window_order<E>(self, expr: E) -> Self::Output
where Self: OrderWindowDsl<E>,

Add a order clause to the current window function Read more
Source§

fn frame_by<E>(self, expr: E) -> Self::Output
where Self: FrameDsl<E>,

Add a frame clause to the current window function Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> MaybeSend for T
where T: Send,