Skip to main content

Crate kui_channel

Crate kui_channel 

Source
Expand description

A data channel (ADR 0065): bulk data the core owns and a handle names, written once and read by index from anywhere that holds the handle — an extension’s fill, another Lua state, a worker thread — so a hundred thousand rows cross into a component as one small value instead of a copy every time they change.

A channel is a table of named, typed columns of one length, or a run of bytes. It is immutable per revision: Channel::publish makes the next revision under the same identity, and a reader holding an older one keeps it until it lets go. Its handle is a value — {"$channel": id, "rev": rev} — so it rides in props, params and messages like any other, and Channel::resolve turns one back into the latest live revision of that identity.

A crate of its own (ADR 0075, decision 3), on kui-value alone, so what has no kui core — the recording’s reader — makes channels too; kui-core re-exports it as kui_core::channel. With the lua feature, [lua] is a channel as a script holds it.

use kui_channel::{Cell, Channel, Column};

let ch = Channel::table(vec![
    ("name".into(), Column::strs(["build", "test", "deploy"])),
    ("ms".into(), Column::F64(vec![12.5, 30.0, 4.0])),
])
.unwrap();
assert_eq!(ch.len(), 3);
let handle = ch.handle();
let again = Channel::resolve(&handle).unwrap();
let ms = again.col("ms").unwrap();
assert_eq!(again.get(1, ms), Cell::F64(30.0));

Structs§

Bucket
One bucket of a Channel::reduce: the least and greatest value among its rows, the first and the last, and the row each was read from — a row of the channel, not of the range. A NaN is no value: it is skipped, and a bucket of nothing but NaN reads NaN for all four, every row its own first, so a line drawn through it breaks there. Ties go to the earliest row.
Channel
One revision of a channel, held: cheap to clone, and the data stays as long as some clone (here or in another binding) does.
ChannelError
Why a channel could not be made.
Lanes
A channel’s intervals on lanes (Channel::lanes): cheap to clone, built once.
Run
One run in a window: a single interval (its row in the channel), or a strip of count of them merged.
Strs
A string column: one buffer and where each string ends, so a hundred thousand names are two allocations.

Enums§

Cell
One cell, borrowed from its channel.
Column
One column: every row’s value of one field, all of one type.
Data
What a channel holds.
Match
What Channel::filter keeps a row for (backlog C148).

Constants§

HANDLE_KEY
The key a handle’s identity rides under.
REV_KEY
The key its revision rides under.

Functions§

column_of
A column from a list of values all of one kind — numbers (integers stay integers only when every one is), booleans or strings — what the bindings build from their own arrays. None names the first value that breaks the kind.
handle_of
The identity and revision a handle names, or None for any other value.
handle_value
A handle’s value for an identity and revision.
is_handle
Whether v is a channel handle.