Skip to main content

content_publisher

Function content_publisher 

Source
pub fn content_publisher(
    options: PublishOptions,
) -> Result<ContentPublisher, Error>
Expand description

Publishes a minimal Inspect Tree server that yields responders for data requests.

This can be thought of like a lazy node, but for the root.

  • Lazy nodes are not supported in Inspectors exposed this way.

Usage:

let mut publisher = content_publisher(options).expect("failed to create publisher");
let mut val = 0;
while let Some(responder) = publisher.next().await {
    // Generate a fresh inspector for each request
    let inspector = Inspector::default();
    inspector.root().record_int("dynamic_data", val);
    inspector.root().record_string("status", "ok");

    // Send the generated VMO
    responder.send(inspector).expect("failed to send inspector");
    val += 1
}