Function reload_state

Source
pub fn reload_state() -> ReloadState
Expand description

Inspect reload state without advancing the game or consuming queued work.

use ferravex_render::content::{queue, reload_state, ContentSource, ReloadStatus};

let mut source = ContentSource::new("embedded", None)?;
queue("replacement")?;
assert_eq!(reload_state().status, ReloadStatus::Pending);
assert_eq!(source.poll(0.0, |text| Ok(text.len())), Some(11));
let accepted = reload_state();
assert_eq!(accepted.generation, 1);
assert_eq!(accepted.last_good_revision, accepted.revision);
queue("replacement")?;
assert!(source.poll::<()>(0.0, |_| panic!("unchanged")).is_none());
assert_eq!(reload_state().last_good_revision, accepted.last_good_revision);
assert_eq!(source.generation(), 1);

Builders keep live game state outside the bridge; replace it only on Some. Structured errors retain the builder’s kind/span and bounded context:

use ferravex_play::authoring::{ContentError, ErrorKind};
use ferravex_render::content::{
    queue, reload_state, ContentSource, ReloadFailure, ReloadOrigin, ReloadStage,
    ReloadState, ReloadStatus, MAX_RELOAD_CONTEXT_BYTES,
};
let mut source = ContentSource::new("embedded", None)?;
let mut live = 7;
queue("invalid")?;
if let Some(next) = source.poll(0.0, |_| Err(ContentError::domain("missing spawn"))) {
    live = next;
}
let state: ReloadState = reload_state();
assert_eq!(state.status, ReloadStatus::Rejected);
let failure: ReloadFailure = state.failure.unwrap();
assert_eq!(failure.origin, ReloadOrigin::QueuedEdit);
assert_eq!(failure.stage, ReloadStage::Build);
assert_eq!(failure.error.kind, ErrorKind::Domain);
assert!(!failure.context_truncated);
assert!(failure.error.context.len() <= MAX_RELOAD_CONTEXT_BYTES);
assert_eq!((live, source.current(), state.generation), (7, "embedded", 0));