Expand description
engate-attach — typed attach lifecycle.
See engate-types for the philosophy + phase markers. This crate
provides the runtime machinery: Producer / Consumer traits,
the typestate-enforced Attach<P> value, the AttachBuilder, and
the linear-ish History<S> handle.
§Quick example
ⓘ
use engate_attach::{Attach, Producer, Consumer};
let attach = Attach::builder()
.producer(my_producer)
.consumer(my_consumer)
.build() // -> Attach<Spawned>
.subscribe()? // -> Attach<Subscribed>, also returns History<S>
.replay(history)? // -> Attach<Synced>
.start_live(); // -> Attach<Live>
// Only an Attach<Live> can render.
attach.run();§Why typestate over runtime FSM
A Result return + match on phase string would also work, but the
compiler would let you write attach.replay() on a Subscribed
that you forgot to subscribe() first. Typestate makes the
malformed call a compile error: Spawned has no replay method;
Subscribed has no start_live method. You CAN’T write the bug.
Structs§
- Attach
- The typed attach handle.
Pis the current phase; the available methods are gated onPso malformed call sequences are compile errors rather than runtime mismatches. - Attach
Config - Builder for the initial
Attach<Spawned>.typed-builderenforces that bothproducerandconsumerare set before.build()can be called. - History
- A snapshot in flight from producer to consumer.
#[must_use]+ runtime drop-bomb together approximate linear typing: forgetting to consumeHistorypanics in debug builds, andclippyflags the dropped result in CI.
Traits§
- Consumer
- A consumer of producer items + snapshots. Mirrors the producer’s associated types so the type-checker enforces compatible pairs.
- Producer
- A producer of live data + bootable snapshots. The trait is the only thing engate needs to provide attach semantics; concrete producers (tear pane, WS channel, K8s log stream) implement it.
Type Aliases§
- Attach
Spawned - Type alias for clarity at call sites.