Skip to main content

DiskStore

Struct DiskStore 

Source
pub struct DiskStore<T: DataPoint> { /* private fields */ }
Expand description

Generic fixed-record binary writer + reader for T: DataPoint.

Layout under <storage_root>/<kind-slug>/<exchange>/<account>/<symbol>/<YYYY-MM-DD>.dat:

  • .dat: append-only, T::RECORD_SIZE bytes per record (little-endian).
  • .idx: sparse [u64 ts_ms, u64 file_offset] every N records.
  • .blob: append-only UTF-8 byte stream (only for types where DataPoint::blob_pointer_offset is Some(_)). Each header’s trailing (blob_offset: u64, blob_len: u32) references a slice in this file.

UTC day rotation. Idx interval is configurable (default 1024).

Implementations§

Source§

impl<T: DataPoint> DiskStore<T>

Source

pub async fn new(storage_root: &Path, key: SeriesKey) -> Result<Self>

Open (or create) a DiskStore. async to match the wasm32 sibling API — the actual work is synchronous; the async wrapper is zero-cost.

Source

pub async fn with_idx_every( storage_root: &Path, key: SeriesKey, idx_every: u32, ) -> Result<Self>

Like new but with a custom idx sparsity factor. async to match the wasm32 sibling API — synchronous internally.

Source

pub fn append(&mut self, point: &T) -> Result<()>

Append one record, possibly rotating to a new UTC day file.

Write order: blob bytes first, header second. Crash mid-blob leaves orphan bytes (no header references them); crash between blob and header still references valid blob range only if the header itself was flushed — partial header is detected on read.

Source

pub fn append_batch(&mut self, points: &[T]) -> Result<()>

Append many points (batch). Same per-record semantics.

Source

pub async fn flush(&mut self) -> Result<()>

Flush OS write buffers. async to match the wasm32 sibling API — synchronous internally. The work completes before the future resolves.

Source

pub async fn read_tail(&self, limit: usize) -> Result<Vec<T>>

Read up to limit most-recent records from the current day’s .dat. Used for warm-start. Returns oldest → newest order.

For types with blob_pointer_offset(), opens the .blob file read-only and reconstructs string fields via DataPoint::decode_blob.

async to match the wasm32 sibling API — synchronous internally.

Source

pub fn key(&self) -> &SeriesKey

Source

pub fn root(&self) -> &Path

Trait Implementations§

Source§

impl<T: DataPoint> Debug for DiskStore<T>

Source§

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

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

impl<T: DataPoint> Drop for DiskStore<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<T> Freeze for DiskStore<T>

§

impl<T> RefUnwindSafe for DiskStore<T>
where T: RefUnwindSafe,

§

impl<T> Send for DiskStore<T>

§

impl<T> Sync for DiskStore<T>

§

impl<T> Unpin for DiskStore<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for DiskStore<T>

§

impl<T> UnwindSafe for DiskStore<T>
where T: UnwindSafe,

Blanket Implementations§

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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