Skip to main content

open_with

Function open_with 

Source
pub fn open_with(
    surface: &AgentSurface,
    sample: &[Value],
    total: usize,
) -> Result<StreamState, AppError>
Expand description

Resolves a stream’s request against its records, before anything is emitted.

sample is a bounded prefix of the records the command is about to write, and total is how many there really are. See gate::evaluate_stream for why it is a prefix and not the whole set.

total exists so the bound gets DECLARED. Scope::vocabulary_is_partial compares the elements it was handed against its own sampling constant, and a prefix of exactly that size compares equal — so a 100 000-record export judged on 64 records would have reported a complete vocabulary. Passing the real count is what turns “I judged a prefix” from an implementation detail into a field on the trailer.

§Errors

Returns AppError::Usage — exit 2 — when a knob cannot act on a stream, or when --select names nothing any record carries. Both happen with stdout still untouched, which is the whole point of resolving up front.