| Crates.io | bird_barrier |
| lib.rs | bird_barrier |
| version | 0.1.0 |
| created_at | 2025-09-05 05:10:06.103504+00 |
| updated_at | 2025-09-05 05:10:06.103504+00 |
| description | A Bevy plugin for coordinating setup/loading tasks with dependency management |
| homepage | |
| repository | https://github.com/Waridley/bird_barrier |
| max_upload_size | |
| id | 1825101 |
| size | 241,450 |
A Bevy plugin for coordinating setup/loading tasks with dependency management.
Like a synchronization barrier in concurrent programming, Bird Barrier ensures all your setup tasks complete before continuing.
Add this to your Cargo.toml:
[dependencies]
bird_barrier = "0.1"
use bevy::prelude::*;
use bevy::ecs::system::SystemId;
use bird_barrier::*;
// Define your setup keys
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
enum MySetupKey {
LoadAssets,
BuildScene,
InitializeGame,
}
impl SetupKey for MySetupKey {
fn register_progress_checker(&self, world: &mut World) -> SystemId<(), Progress> {
match self {
MySetupKey::LoadAssets => world.register_system(check_assets_loaded),
MySetupKey::BuildScene => world.register_system(check_scene_built),
MySetupKey::InitializeGame => world.register_system(check_game_initialized),
}
}
}
fn check_assets_loaded() -> Progress {
// Your progress checking logic here
Progress::DONE
}
fn check_scene_built() -> Progress {
Progress::DONE
}
fn check_game_initialized() -> Progress {
Progress::DONE
}
fn load_assets() {
println!("Loading assets...");
}
fn build_scene() {
println!("Building scene...");
}
fn initialize_game() {
println!("Initializing game...");
}
fn setup_complete() {
println!("Setup complete!");
}
fn main() {
App::new()
.add_plugins(SetupTrackingPlugin::<MySetupKey, _, _, _>::new(
// Condition: always run (you might want to use a state condition)
|| true,
// On finished callback
setup_complete,
))
// Register your setup providers
.register_provider(
load_assets.provides([MySetupKey::LoadAssets])
)
.register_provider(
build_scene
.requires([MySetupKey::LoadAssets])
.provides([MySetupKey::BuildScene])
)
.register_provider(
initialize_game
.requires([MySetupKey::BuildScene])
.provides([MySetupKey::InitializeGame])
)
.run();
}
Setup keys represent different stages or components of your application's initialization. They must implement the SetupKey trait, which requires:
Providers are systems that contribute to the setup process. This concept is similar to:
httpd)Each provider can:
This separation allows you to define what your setup steps need without tightly coupling them to specific implementations.
The system automatically tracks progress by:
Bird Barrier includes examples demonstrating different usage patterns:
basic_usage.rs - Simple enum-based keys (recommended starting point)trait_object_keys.rs - Advanced trait object-based keys for polymorphic setup providersvisualization.rs - Interactive graph visualization (requires visualization feature)The crate provides several helper functions for common progress checking patterns:
single_spawn_progress<F>(): Check if an entity with filter F existsresource_progress<R>(): Check if resource R existsstate_progress<S>(state): Check if the app is in a specific stateassets_progress<C>(): Check asset loading progress for collection CLicensed under either of
at your option.
The original implementation was entirely written by me for use in Mt. Thyrios. I then used the Augment Code plugin in CLion to help extract it out into a separate crate, add documentation, examples, and tests. I consider this a reasonable usage of LLM technology, but if it is unacceptable to you, I sincerely apologize and I promise I do understand your concerns. We're all trying to navigate this new paradigm in our own ways.