pub struct StatusBridge { /* private fields */ }Expand description
Fixed retained storage, no allocations during ordinary publication. See module example for complete usage. O(128² + 128×1025 + MAX_WIRE_BYTES) bounded work; labels are measured by byte length without scanning oversized source text.
Implementations§
Source§impl StatusBridge
impl StatusBridge
Sourcepub fn new(owner: u64) -> Result<StatusBridge, StatusError>
pub fn new(owner: u64) -> Result<StatusBridge, StatusError>
Start an unpublished bridge. No default snapshot or browser adoption.
use ferravex_render::{status::*, ui::*};
let mut ui = Ui::new();
ui.set_inspection_enabled(true);
ui.begin(Viewport::responsive([640., 480.], [0.; 4]).unwrap());
ui.button(7, UiRect { min: [20.; 2], size: [160., 48.] },
"Resume", true, ButtonStyle::default()).unwrap();
ui.finish(false); // No input requested by this headless recipe.
let mappings = [UiAction { widget_id: 7, status_id: 20 }];
let mut status = StatusBridge::new(100)?;
status.publish(Some(StatusFacts { items: &[], ui: ui.inspect(),
ui_actions: &mappings }))?;
let mut output = [0; 1024];
let length = status.write(&mut output)?;
assert!(std::str::from_utf8(&output[..length]).unwrap().contains("Resume"));
status.reset()?;
assert!(status.bytes().is_empty());Sourcepub fn publish(
&mut self,
facts: Option<StatusFacts<'_>>,
) -> Result<StatusUpdate, StatusError>
pub fn publish( &mut self, facts: Option<StatusFacts<'_>>, ) -> Result<StatusUpdate, StatusError>
Validate the entire bounded source before replacing publication. Rejects duplicates even in the omitted suffix. At most one lifecycle and result. UI maps select only registered, enabled, clipped-in buttons; absent/disabled buttons are unavailable actions, not truncation. Missing full labels count as omissions; their painter abbreviation is never substituted.
Sourcepub fn bytes(&self) -> &[u8] ⓘ
pub fn bytes(&self) -> &[u8] ⓘ
Current initialized JSON prefix only; empty before publish/after reset.
Sourcepub fn write(&self, output: &mut [u8]) -> Result<usize, StatusError>
pub fn write(&self, output: &mut [u8]) -> Result<usize, StatusError>
Atomic caller-buffer copy; tail is untouched and never part of the wire.
Sourcepub fn reset(&mut self) -> Result<(), StatusError>
pub fn reset(&mut self) -> Result<(), StatusError>
New epoch; same owner and storage. Call publish_browser again if adopted so readers see unavailable until the next complete publication.
Sourcepub fn publish_browser(&self) -> Result<(), StatusError>
pub fn publish_browser(&self) -> Result<(), StatusError>
Explicit copy to this thread’s readonly export slot. Another owner must
clear its slot before replacement. Repeated identical copies are no-ops.
Host must call clear_browser on teardown; this does not retain self.