Skip to content
API REFERENCEUsage guides →

Errors and crate-root exports ​

The crate has two error domains. Storage, codecs, metadata and runtime use cellpack::Error / cellpack::Result<T>. Loading and planning use cellpack::loader::Error / loader::Result<T>. The root also re-exports CpkFile and CpkWriter for convenience.

Start with the failing operation

This page explains what to report and what can be reused. For a working consumption pattern, see loading and ownership; for the exact validated/trusted boundary, see data contracts.

Format, codec, and storage errors ​

VariantMeaningRecovery scope
InvalidInput / InvalidOptionsAn argument or declaration violates the APICorrect inputs/options before retrying
OutputTooSmall { need, have }Output extent differs from the required sizeUse the operation's sizing contract; exact-size calls can also reject oversized buffers
WorkspaceTooSmallScratch is undersizedAllocate the requested number of u64 words
OutputTypeTooNarrowIndex/offset type cannot hold a required valueUse a wider output integer type
RowOutOfRangeRequested row/cell/chunk position is invalidCorrect the selector and id space
TablesMismatchTables belong to different metadataRebuild/bind the correct tables
CorruptMeta / CorruptRecordAn explicitly checked consistency rule failedReject the affected input/output
IoFile operation failedInspect preserved error kind and message

These errors do not imply every malformed record is checked. Trusted inner-record corruption can violate optimized decoder assumptions. After a failed read/decode, discard potentially partial output.

OutputTooSmall sizes follow the particular operation's output unit; they are not universally byte counts. WorkspaceTooSmall always reports u64 words. Use the shape and capacity reference rather than inferring allocation units from the variant name.

Error::Io { kind, message } preserves the OS error kind and formatted message, not the original std::io::Error object. Match kind for programmatic decisions and retain message for diagnostics. CorruptRecord reports an explicit failed comparison; it is not evidence that decoding arbitrary damaged records is safe.

Loader and planner errors ​

VariantMeaningRecovery scope
Config(String)Invalid declaration or protocol useCorrect configuration or call order
Access { position, cell }Sequence names a cell outside the sourceposition is the access index k; check registration ranges and schema expansion
IoOS I/O failure or short readInspect the OS error and input/storage state
CellPackWrapped format/codec/storage errorPreserve and inspect its underlying cause
Plan(String)Incompatible plan, costs or planning optionsCorrect options or recompile for the actual graph
Process(status)Native process callback failedInterpret application-defined status
Accesses(status)Native sampling callback failedInterpret application-defined status
WorkerPanicA worker or compiler thread panickedFail the run and inspect diagnostics
BusyA loader/run or ring producer is already occupiedFinish the existing work and drop its run handle before retrying
AbortedCancellation was observedStop this run; identify its originating cause

For S schemas, access index k belongs to logical position k / S and schema index k % S. The field name position in Error::Access does not refer to that logical position. A wrong cell may originate in a native sampler, a stored sequence, or an incorrect per-schema offset.

Preserve the cause ​

loader::Error::Io retains its std::io::Error; CellPack retains the underlying cellpack::Error. Both participate in std::error::Error::source(). Report the operation context with the error chain, rather than replacing it with a generic "loading failed" message. Callback statuses are application-defined nonzero codes, not portable OS error numbers.

A producer or worker failure cancels other participants, which can then report Aborted. The producer joins its threads and prefers a non-Aborted cause over secondary cancellation. for_each_batch also preserves a consumer callback's error; if consumption only observed cancellation, it returns the producer's result instead. With several concurrent failures, this is not a guarantee of which failure happened first in wall-clock time.

Decide what to reuse ​

Failure pointMeaning for the next attempt
Source/schema/plan construction or rejected prepareCorrect the declaration or file state. No successful prepared run was returned
BusyAnother owner is active; it is not a request to abort that owner's work
Config saying the ring has ready/leased slotsConsume remaining ready output and release leases after successful production, or use a fresh ring
Failure during producer execution, or a Run::wait errorThe run is cancelled; its ring is permanently aborted
Explicit Run::cancel or dropping a prepared but unstarted runThe ring is permanently aborted
Successful runDrain output, release every lease, and drop the old run handle before reusing the loader and ring

An aborted ring cannot be reset or prepared again. Allocate a fresh ring for a new attempt after fixing the originating cause. Keep old backing storage alive while any lease still references it, and discard incomplete output. A wrong-rank wait is a protocol error that cancels the run even though its variant is Config; the variant alone does not tell you whether a run remains usable.

If progress stops without an error, check backpressure and held leases before treating the wait as an I/O failure.

Root interface index ​

The crate root exports Error, Result, CpkFile and CpkWriter. Loading and planning use their own loader::Result, so qualify the result type when combining the two domains in one module. Other interfaces live in their named modules.

Re-exports ​

InterfaceResponsibility
CpkFileAn opened .cpk file.
CpkWriterWrites one matrix to a .cpk file. Rows are appended in order; the file is valid only after CpkWriter::finish .

Enums ​

InterfaceResponsibility
ErrorWhy an operation failed.

Type Aliases ​

InterfaceResponsibility
ResultThe crate’s result type.
Definition