grafbase_sdk/host_io/
pubsub.rs

1//! Subscriber module providing interfaces for consuming field outputs from streams.
2//!
3//! This module defines the core `Subscriber` trait that abstracts over different
4//! implementations of subscribing to field output streams, allowing extensions to
5//! handle field outputs in a transport-agnostic way.
6
7use crate::{types::FieldOutput, Error};
8
9pub mod nats;
10
11/// A trait for subscribing to a stream of field outputs.
12pub trait Subscriber {
13    /// Gets the next field output from the stream.
14    ///
15    /// Returns `Ok(Some(output))` if a field output is available,
16    /// `Ok(None)` if the stream has ended, or `Err` if an error occurred.
17    fn next(&mut self) -> Result<Option<FieldOutput>, Error>;
18}