pub struct PostgresCopyHandler<'a> { /* private fields */ }Expand description
Handles PostgreSQL COPY BINARY operations for blockchain data.
Implementations§
Source§impl<'a> PostgresCopyHandler<'a>
impl<'a> PostgresCopyHandler<'a>
Sourcepub const fn new(pool: &'a PgPool) -> Self
pub const fn new(pool: &'a PgPool) -> Self
Creates a new COPY handler with a reference to the database pool.
Sourcepub async fn copy_blocks(&self, chain_id: u32, blocks: &[Block]) -> Result<()>
pub async fn copy_blocks(&self, chain_id: u32, blocks: &[Block]) -> Result<()>
Inserts blocks using PostgreSQL COPY BINARY for maximum performance.
This method is significantly faster than INSERT for bulk operations as it bypasses SQL parsing and uses PostgreSQL’s native binary protocol.
§Errors
Returns an error if the COPY operation fails.
Sourcepub async fn copy_tokens(&self, chain_id: u32, tokens: &[Token]) -> Result<()>
pub async fn copy_tokens(&self, chain_id: u32, tokens: &[Token]) -> Result<()>
Inserts tokens using PostgreSQL COPY BINARY for maximum performance.
§Errors
Returns an error if the COPY operation fails.
Sourcepub async fn copy_pools(&self, chain_id: u32, pools: &[Pool]) -> Result<()>
pub async fn copy_pools(&self, chain_id: u32, pools: &[Pool]) -> Result<()>
Inserts pools using PostgreSQL COPY BINARY for maximum performance.
§Errors
Returns an error if the COPY operation fails.
Sourcepub async fn copy_pool_swaps(
&self,
chain_id: u32,
swaps: &[PoolSwap],
) -> Result<()>
pub async fn copy_pool_swaps( &self, chain_id: u32, swaps: &[PoolSwap], ) -> Result<()>
Inserts pool swaps using PostgreSQL COPY BINARY for maximum performance.
§Errors
Returns an error if the COPY operation fails.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for PostgresCopyHandler<'a>
impl<'a> !RefUnwindSafe for PostgresCopyHandler<'a>
impl<'a> Send for PostgresCopyHandler<'a>
impl<'a> Sync for PostgresCopyHandler<'a>
impl<'a> Unpin for PostgresCopyHandler<'a>
impl<'a> !UnwindSafe for PostgresCopyHandler<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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