Skip to main content

IpcWriteContext

Struct IpcWriteContext 

Source
pub struct IpcWriteContext {
    scratch: Vec<u8>,
    reserve_scratch: bool,
    fbb: FlatBufferBuilder<'static>,
    lz4_block_size: Option<Lz4BlockSize>,
    compressor: Option<Compressor<'static>>,
    lz4_compressor: Option<Lz4Compressor>,
}
Expand description

Additional context that may be needed for compression.

In the case of zstd, this will contain the zstd context, which can be reused between subsequent compression calls to avoid the performance overhead of initialising a new context for every compression. In the case of lz4, this will contain the lz4 frame encoder, whose hash table and block buffers are likewise reused; its block size is configurable through crate::writer::IpcWriteOptions::try_with_lz4_block_size. Also holds a [FlatBufferBuilder] that is reused across IPC writes.

Fields§

§scratch: Vec<u8>§reserve_scratch: bool§fbb: FlatBufferBuilder<'static>§lz4_block_size: Option<Lz4BlockSize>

The lz4 frame block size to build a cached encoder with; None selects the default.

§compressor: Option<Compressor<'static>>§lz4_compressor: Option<Lz4Compressor>

Implementations§

Source§

impl IpcWriteContext

Source

pub(crate) fn mut_fbb(&mut self) -> &mut FlatBufferBuilder<'static>

Get a mutable reference to the [FlatBufferBuilder] that is reused across IPC writes.

Source

pub fn set_reserve_scratch(&mut self, reserve: bool)

Set whether the scratch buffer capacity should be reserved after each encode for reuse on the next call. Set to false for the final batch in a sequence to avoid a pointless allocation. by default, this is set to false.

Source

pub(crate) fn reserve_scratch_with_capacity(&mut self, additional: usize)

Reserve the scratch buffer capacity for reuse on the next call. This is a no-op if reserve_scratch is set to false.

Source

pub(crate) fn scratch(&mut self) -> Vec<u8> ⓘ

Source

pub(crate) fn set_lz4_block_size(&mut self, block_size: Lz4BlockSize)

Set the lz4 frame block size used by the cached lz4 encoder.

A cached encoder is dropped when the size changes so the next compression call builds one with the new block size.

Source

fn zstd_compressor(&mut self, level: i32) -> &mut Compressor<'static>

Source

fn lz4_compressor(&mut self) -> &mut Lz4Compressor

Trait Implementations§

Source§

impl Debug for IpcWriteContext

Source§

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

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

impl Default for IpcWriteContext

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for IpcWriteContext

§

impl Freeze for IpcWriteContext
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<FieldLoc>: Freeze, PhantomData<u32>: Freeze, PhantomData<WIPOffset<&'static str>>: Freeze, PhantomData<&'static ()>: Freeze, *const ZSTD_CCtx_s is !null: Freeze, *const ArcInner<CDictInner> is !null: Freeze, PhantomData<ArcInner<CDictInner>>: Freeze, *const ZSTD_CDict_s is !null: Freeze, *const dyn Sync + Send is !null: Freeze, *const [u32; 4096] is !null: Freeze, PhantomData<[u32; 4096]>: Freeze,

§

impl Move for IpcWriteContext

§

impl RefUnwindSafe for IpcWriteContext

§

impl Send for IpcWriteContext
where RawVecInner: Send, &'static str: Send, &'static (): Send, CCtx<'static>: Send, BoxRaw<[u32; 4096]>: Send,

§

impl Sync for IpcWriteContext
where RawVecInner: Sync, CCtx<'static>: Sync, BoxRaw<[u32; 4096]>: Sync,

§

impl Unpin for IpcWriteContext
where *const u8 is !null: Unpin, &'static str: Unpin, &'static (): Unpin, *const ZSTD_CCtx_s is !null: Unpin, Arc<CDictInner>: Unpin, *const ZSTD_CDict_s is !null: Unpin, *const dyn Sync + Send is !null: Unpin, Box<[u32; 4096]>: Unpin,

§

impl UnsafeUnpin for IpcWriteContext
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, PhantomData<FieldLoc>: UnsafeUnpin, PhantomData<u32>: UnsafeUnpin, PhantomData<WIPOffset<&'static str>>: UnsafeUnpin, PhantomData<&'static ()>: UnsafeUnpin, *const ZSTD_CCtx_s is !null: UnsafeUnpin, *const ArcInner<CDictInner> is !null: UnsafeUnpin, PhantomData<ArcInner<CDictInner>>: UnsafeUnpin, *const ZSTD_CDict_s is !null: UnsafeUnpin, *const dyn Sync + Send is !null: UnsafeUnpin, *const [u32; 4096] is !null: UnsafeUnpin, PhantomData<[u32; 4096]>: UnsafeUnpin,

§

impl UnwindSafe for IpcWriteContext
where RawVecInner: UnwindSafe, &'static str: UnwindSafe, &'static (): UnwindSafe, NonNull<ZSTD_CCtx_s>: UnwindSafe, Arc<CDictInner>: UnwindSafe, NonNull<ZSTD_CDict_s>: UnwindSafe, Owner: UnwindSafe, BoxRaw<[u32; 4096]>: UnwindSafe,

Blanket Implementations§

§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.