Expand description
§egui-pop-hooks
egui-pop’s hook kernel, now bus-kernel:
this crate re-exports it, so egui_pop_hooks::Kernel and every other
path of 0.2 still name the same items.
bus-kernel is an implementation of
bus-contract: typed hook
points, listeners with ids ordered by after/before and priority,
alter and collect emits, a per-listener error boundary with panics
caught and deadlines, local listeners, deferred requests, timings, and a
host journal and relay. It needs no GUI toolkit, and ships a conformance
suite (its conformance feature) any other implementation can run.
New code may depend on bus-kernel directly. egui-pop’s application
uses this kernel by default (AppBuilder::bus supplies another).
License: MIT OR Apache-2.0.
Experimental: may change in any release
(docs/stability.md).
Re-exports§
pub use bus_kernel;
Modules§
- bus_
contract - bus-contract
- bus_
contract_ crossing - bus-contract-crossing
- bus_
contract_ defer - bus-contract-defer
- bus_
contract_ journal - bus-contract-journal
- bus_
contract_ timings - bus-contract-timings
- trace
- The trace tap: each emit, each listener heard, each ask and its drain, reported as it happens to the sinks that observe the kernel.
Structs§
- Altered
- The result of an
alteremit. - Codec
- How a relayable point’s input is written and read
(
Relayed), and a relayable request’s value (RelayedRequest), its types erased, for a contract table (relayable). Two codecs are equal when they are for the same point. - Collected
- The result of a
collectemit. - Contract
- A capability contract a bus may offer: its name, its version line and
the trait object type a bus answers for in
Bus::capability. Each contract crate exports one asCONTRACT(bus_contract_journal::CONTRACT); a point names those it needs in its table (PointDecl::needs) anddeclare_allrefuses it on a bus without them. - Crossing
- What an authority of a bus is shown of something crossing in
(
Relay::add_authority), before anything is decoded or recorded. - Cursor
- Where a reader of a relay stands: the journal run it read and the last number it took.
- Facet
- What a point’s declaration says for one capability contract: the
contract, and data only that contract’s crate reads (a journaled
mark, a codec). Made by the contract crate, in a
const(bus_contract_journal::JOURNALED,bus_contract_crossing::relayable(&CODEC)), and carried byPointDecl::facetsandPointSpec::facets. A point with a facet needs its contract. - Failure
- One listener’s failure: its contribution was dropped (except for a
FailureKind::MissingTarget); the other listeners ran, unless the point is fail-closed (PointSpec::fail_closed). - Journal
Entry - One event of a journal: what happened, its number, what caused it.
- Kernel
- The hook kernel: hook points, their listeners, emits and
introspection.
Send + Sync: share it in anArc. Listeners run with no lock held, so a listener may emit or listen itself. - Listen
Opts - How a listener is placed and limited.
- Listener
Id - A listener’s id, checked when made against the naming rule
(
check_id):<crate>.<what>(docs.autosave), so the order dump of a point shows who each listener belongs to. - Listener
Info - A listener as introspection shows it.
- Listener
Timings - One listener’s time on a point (
PointTimings::listeners). - Observing
- Keeps a sink observing a bus (
Trace::add_trace_sink); dropping it removes the sink. - Origin
- Who sent what crosses a process boundary: the far side of a link, as the receiving side knows it.
- Over
Budget - A pass of a point’s listeners that went over its budget
(
PointSpec::budget): reported to the budget sinks (Timings::add_budget_sink). The pass’s results were kept: a budget is not a deadline. - Pending
Run - What listeners run later did: one emit’s local listeners queued for
their thread (
Bus::run_pending), or one deferred request (the defer contract’s drain). - Point
Decl - One line of a library’s contract table: a point it declares, built
from the point’s type in a
const(PointDecl::of::<DocClose>(…)), so the application can read what a library will host before building anything.declare_alldeclares a table on a bus. - PointId
- A point’s id (
Point::ID), checked when made against the naming rule (check_id):<crate>.<subject>.<moment>. - Point
Info - A point as introspection shows it.
- Point
Spec - A point’s declaration: its description and limits, for introspection.
- Point
Timings - A point’s time (
Timings::points): its passes, its listeners, its budget and how often a pass went over. - Refusal
- A request stopped by one of its listeners: the listener refused it
(
HookError::Refuse), or failed on a fail-closed point (PointSpec::fail_closed). The listeners after it did not run. - Relayed
Answer - The answer to one ask (
Relay::answer), naming it. - Relayed
Ask - A request asked of another process (
Relay::answer): its input and the value so far, as text, with the time the asker waits. - Relayed
Entry - An event as it crosses a process (
Relay): its input as text. - Resumed
- What a relay read found (
Relay::resume). - Since
- What a read of a journal after a number found (
Journal::since). - Timing
Stats - How long something took over a window of runs
(
Timings): a listener’s runs, or a point’s passes. The quantiles may be approximate (an implementation may read them from a histogram); the count, total and max are exact. - Trace
Event - One thing the bus did, as a sink receives it.
Enums§
- Answer
- How an ask was answered (
RelayedAnswer::answer). - Failure
Kind - What went wrong with one listener during an emit.
- Hook
Error - What a listener returns instead of
Ok(()): it failed, or it refuses the request. - IdError
- Why an id was refused (
check_id). - Ingest
Error - Why an entry relayed in was not taken (
Relay::ingest). - Lost
- Why a reader of a relay missed entries (
Resumed::lost). - Outcome
- What a listener answered (
Traced::Heard), before the point’s rules judge it: a refusal on a point that is not a request counts as a failure there. - Point
Kind - What a point is for, declared for introspection and review. A request
is an alter emit over the request’s input; only a request can be
refused by a listener (
HookError::Refuse) or declared fail-closed (PointSpec::fail_closed). - Refused
- Why a declaration or a listener was refused. Nothing was changed.
- Traced
- What a
TraceEventreports.
Constants§
- DEFAULT_
DEADLINE - The deadline of an in-process listener when neither the listener nor its point sets one.
- FAILED_
FACT - The name a host gives the fact it publishes for each
Failureits sinks receive (Bus::add_failure_sink). - JOURNALED
- The facet of a journaled event point: its events go through the
bus’s journal, published with a number and delivered to the
listeners in journal order after the publisher has moved on
(
PointDecl::of::<P>(…).facets(&[JOURNALED]), orPointSpec::new(…).facet(JOURNALED)). Only an event point is journaled (check). - LAST
- The
aftertarget that places a listener after every other listener of its point (ListenOpts::last): one per point, a second is refused as aRefused::Cycle(each would run after the other). - OVER_
BUDGET_ FACT - The name a host gives the fact it publishes for each
OverBudgetits budget sinks receive (Timings::add_budget_sink). - PLUGIN_
DEADLINE - The deadline meant for listeners that answer from another process (a
plugin over RPC): give it with
ListenOpts::deadlineorPointSpec::deadline.
Traits§
- BusCrossing
- Reaches the
Relaycapability of any bus:bus.relay(). - BusDefer
- Reaches the
Defercapability of any bus:bus.defer(). - BusJournal
- Reaches the
Journalcapability of any bus:bus.journal(). - BusTimings
- Reaches the
Timingscapability of any bus:bus.timings(). - BusTrace
- The trace of a bus, found through its capability lookup.
- Defer
- A capability of a bus (
BusDefer::defer): a request asked now, whose listeners run at the bus’s next drain on the same thread. - Journal
- A capability of a bus (
BusJournal::journal): events kept in order with a number, read again from a number, and delivered to their point’s listeners after the publisher has moved on. - Point
- A hook point: one type per point, so its input and value are checked at compile time. Declared by the crate that owns the result.
- Relay
- A capability of a bus (
BusCrossing::relay), on top of itsJournal: what crosses a process boundary. The events of relayable points served to another process from a cursor and taken in from one as if published here; the asks of relayable request points answered here for another process. - Relay
Host - What a host keeps for the kernel’s
Relay(Kernel::with_relay): its journal’s entries read from a cursor and taken in from another process. The kernel answers asks and checks authorities and versions itself; the host only reads and records. - Relayed
- An event point whose input can cross a process: written as text by
one bus, read back by another (
Relay). - Relayed
Request - A request point that can be answered by another process
(
Relay::answer): its value, as well as its input, written as text and read back. - Timings
- A capability of a bus (
BusTimings::timings): how long listeners take, per point and per listener, and the passes over a point’s budget (PointSpec::budget) reported as they happen. - Trace
- A capability of a bus (
BusTrace::trace): every emit, listener run, ask and drain reported to the sinks observing it, as it happens.
Functions§
- ask_run
- This process’s run, for the asks it sends (
RelayedAsk::run): fixed while the process runs, another one after a restart. - check_
id - Checks
idagainst the naming rule of point and listener ids,<crate>.<subject>.<moment>(the README’s “Naming points”): - declare_
all - Declares every point of a library’s contract table on
bus; the refusals, in table order, each point refused left undeclared: - far_
listener - The listener that stands, on the asking side, for the far side of a relayable request point: register it on the point here (with the point’s deadline and threaded, so the emit stops waiting at the deadline), and the far side’s listeners take their turn in this side’s order, at its place.
- kind_
matches - Whether the event kind
kindmatchespattern: the same id, or a prefix ending in.*(vault.*matchesvault.changed), or*for every kind. Every implementation reads patterns this way. - missing_
targets - The ordering constraints of
pointsthat name a listener not there:point: listener -> target. A test ends with none. - offers
- Whether
busofferscontract: it answers the lookup for the contract’s type (Bus::capability), and offers every contract it requires. - order_
dump - The order the listeners of
pointsrun in, one point after the other, each listener with its owner and what it declares: “who runs when”, read rather than remembered.
Type Aliases§
- Authority
- Decides whether what crosses in may be taken (
Relay::add_authority):Err(reason)refuses it. - Trace
Sink - Receives each
TraceEvent, on the thread that made it.