Skip to content
API REFERENCEUsage guides →

Rust API ​

Find the interface for your task, try it on a small matrix, then follow its exact declaration and ownership rules. This reference covers the Rust crate cellpack.

Type names inside declarations are clickable: open a definition beside the page, inspect its source, or continue to the full API entry. Run example executes a fixed, prebuilt program on the configured server. Code is read-only. Enable LSP for type information and definition lookup within the current example file. Runnable examples explain the shared fixture and local setup.

Start with a task ​

I want to…Start hereWhat to watch
Write matrix rows to a fileCpkWriterDeclare the input dtype/layout; call finish before opening the file
Read or reorder selected rowsReadSelectionFile-row IDs, output element counts, and exclusive workspace
Map columns into another orderCpkFile::prepare_selectionThe map is source → output; lists preserve row repetitions
Produce batches for trainingLoaderSource → schemas → accesses → ring → run
Consume batches safelyRunOverlap production and consumption; release leases when readers finish
Generate an access orderAccessesGlobal cell IDs; calls may be concurrent, repeated, or out of order
Reuse cached pages and rowsPlans and costsCache capacity is not total RSS; modeled time is not measured time
Encode records in my own containerCodecsCaller buffers, matching metadata, and trusted-record requirements

The main workflows ​

Write once, read selected rows
  1. 01
    CreateCpkWriter::create

    Declare dtype, layout and column count.

  2. 02
    Appendappend

    Add matching matrix rows in order.

  3. 03
    Finishfinish

    Publish the complete stream before reading.

  4. 04
    OpenCpkFile::open

    Read the finalized stream.

  5. 05
    Prepareprepare_read

    Bind row selection and output dimensions.

  6. 06
    Readread_dense_into

    Decode into caller-owned output.

The caller owns the output and can reuse ReadWorkspace after each read.

Build an ordered delivery pipeline
  1. 01
    Register sourcesDataSourceBuilder

    Bind files and source-to-standard column maps.

  2. 02
    Declare outputsOutputSchema

    Choose panels, dtypes and optional processing.

  3. 03
    Bind executionLoader

    Construct a loader with worker and I/O settings.

  4. 04
    Prepare a runprepare

    Bind accesses, compatible ring and planning mode.

  5. 05
    Consume batchesRun::for_each_batch

    Read ordered output while production runs.

Keep leases alive until readers finish; every slot is bounded reusable storage.

Use data contracts for units, dtype conversions, ID spaces, and lifetime rules.

Choose a module ​

ModuleResponsibilityInputOutput
Matrix storage: storeStreaming files and ordered selectionsMatrix row batches, files, selectors.cpk streams and typed matrix buffers
Codecs: scansEncoding, decoding, packing, casting and mappingBorrowed bytes, metadata, tables, workspaceEncoded bytes, decoded arrays, borrowed row parts
Metadata: formatParse and inspect byte layoutsStream/chunk metadata bytesBorrowed views and owned directory records
Data delivery: loaderSources, schemas, sequences, workers, rings and process ABIImmutable input files and deterministic access requestsOrdered batches with per-schema byte regions
Planning: optFrame residency and cost-guided compilationGraph, sequence, cache budget, cost modelPlans, replay summaries and online statistics
Timing: profSelected timing sites and report aggregationSite masks and per-thread measurementsSite, detail and histogram reports
Process settings: runtimeKernel binding and core topologyExplicit options or environmentProcess-lifetime runtime and physical-core count
Errors and root exportsError domains and convenience importsOperation results and failure causesTyped errors and recovery scope

Browse interfaces ​

Search by name or responsibility, then filter by module and kind. Quick view keeps your place while showing the declaration and a source excerpt.

206 interfaces

Errorenum

Why an operation failed.

Numeric type of a matrix’s values; its width is the chunks’ value width.

Parses and checks the directory against its superblock: the hash, rows that tile 0..n_rows in order, and page-aligned, ascending, non-overlapping chunks after the superblock and before the directory.

Parses a superblock (at least SUPERBLOCK_LEN bytes) and checks its fields against each other; the hash is checked by parse_directory .

One chunk: rows first_row..first_row + n_rows at offset , len bytes of which the first meta_len are its metadata.

Parses metadata from the start of bytes (the metadata alone or a whole chunk). Checks the header and section sizes; per-cell table entries are checked where they are read.

Element count of a record from its header alone: the varint after the flags byte (0 for an empty record). For a sparse record it counts stored entries (explicit zeros included); for a dense record, non-zero values. A caller can compare it with metadata before committing to a decode.

Interpretation of a chunk’s metadata bytes. Holds no data of its own: header fields are decoded once, sections are borrowed.

Immutable metadata bytes and a validated descriptor. Views borrow only this owner; section offsets avoid self-referential pointers and lifetime extension.

Classes in Conversion ’s numbering; the cost model’s table size.

The process ABI the loader implements: the layout of ProcessContext , CsrRow and DenseRow . A callback built against another version must not be passed to ProcessFn .

Element-count boundaries of the process site’s size bands; a call’s element count (output dims for a dense record, stored elements otherwise) belongs to the band below the first boundary above it.

Cost classes of conversions, as the cost model prices them.

How a worker reads: the platform’s asynchronous ring, or blocking preadv.

Whether values stored as s may be output as t : the same type, lossless widening, same-width signed to unsigned (negatives are not checked), signed to wider unsigned, and any integer to a float.

Borrowed slot lease. Output references cannot outlive this guard.

Owned slot lease, suitable for foreign-runtime array base objects.

A CSR row: nnz stored elements with output columns in the chunk’s coded order (not sorted) and values of the schema’s dtype. Every other output dim is a zero or missing (see the module notes). A dense record delivered as a CSR row lists its non-zeros.

Every input matrix, numbered by global cell id, with each matrix’s map from its columns to the standard ids (the data side of the panel). Shared by planner and workers.

A dense row: out_dim values of the schema’s dtype: the stored value or 0 at present dims, the schema’s default at missing dims (see the module notes).

Read statistics of one worker, summed over workers in RunStats .

One data source and the schemas that output its cells, ready to serve runs.

How a loader’s runs execute: threads, I/O backend, windowing and profiling.

Bytes a run reserves, by purpose. Each term is a known reservation, not a measured footprint: allocator overhead, the compiler’s own state and the OS page cache are outside it, and reserved bytes need not be resident.

The module indexes enumerate every documented public item, including supporting enums, constants, traits and low-level helpers. Detail pages are regenerated from the crate source at build time. Public signatures, field types and method lists are therefore linked to the build, while semantic contracts are maintained in the module references.

Read contracts before composing layers ​

Declarations, member links, implemented traits, and source excerpts come from the same build. Parameter explanations and worked examples add the usage context.

Definition