pub struct TypedTableView<S: Schema, C: ConsumerApi + Clone = Consumer> { /* private fields */ }Expand description
Schema-aware TableView. Wraps a raw TableView plus an Arc<S> and exposes
typed accessors that decode the payload on demand. Mirrors Java’s
pulsar.tableView(Schema) shape.
Engine-generic. Defaults C = magnetar_runtime_tokio::Consumer so
existing call sites (TypedTableView<MySchema> without a second
type argument) keep resolving to the tokio specialisation.
Implementations§
Source§impl<S: Schema + 'static, C: ConsumerApi + Clone> TypedTableView<S, C>
impl<S: Schema + 'static, C: ConsumerApi + Clone> TypedTableView<S, C>
Sourcepub fn inner(&self) -> &TableView<C>
pub fn inner(&self) -> &TableView<C>
Borrow the underlying raw TableView. Useful for the unchanged getters
(len, is_empty, keys, listener registration, etc.).
Sourcepub fn get(&self, key: &str) -> Result<Option<S::Owned>, PulsarError>
pub fn get(&self, key: &str) -> Result<Option<S::Owned>, PulsarError>
Decode the value for key. Returns Ok(None) when the key is absent, Err when
decoding the stored bytes against the schema fails.
Sourcepub fn snapshot(&self) -> Result<HashMap<String, S::Owned>, PulsarError>
pub fn snapshot(&self) -> Result<HashMap<String, S::Owned>, PulsarError>
Decode every currently-known value. Allocates; use Self::for_each to avoid the
HashMap allocation when streaming. Errors stop at the first decode failure.
Sourcepub fn for_each<F>(&self, f: F)
pub fn for_each<F>(&self, f: F)
Iterate every currently-known (key, decoded value) pair. The callback receives
Result<S::Owned, SchemaError> so per-key decode failures don’t abort the iteration.
Sourcepub fn listen<F>(&self, callback: F)
pub fn listen<F>(&self, callback: F)
Register a typed listener fired for every mutation. The callback receives the
pre-decoded value (or None for a tombstone). Decode failures replace the value
with None so the listener is never poisoned by a single bad payload. The
callback runs inside the drain task — keep it fast and non-blocking.