Skip to content

Commit 33afd38

Browse files
show these 'fully qualified paths' for bevy_remote's rpc (#16944)
# Objective It is not obvious that one would know these: ```json { "id": 1, "jsonrpc": "2.0", "result": [ "bevy_animation::AnimationPlayer", "bevy_animation::AnimationTarget", "bevy_animation::graph::AnimationGraphHandle", "bevy_animation::transition::AnimationTransitions", "bevy_audio::audio::PlaybackSettings", "bevy_audio::audio::SpatialListener", "bevy_core_pipeline::bloom::settings::Bloom", "bevy_core_pipeline::contrast_adaptive_sharpening::ContrastAdaptiveSharpening", **... snipping for brevity ...** "bevy_ui::ui_node::Node", "bevy_ui::ui_node::Outline", "bevy_ui::ui_node::ScrollPosition", "bevy_ui::ui_node::TargetCamera", "bevy_ui::ui_node::UiAntiAlias", "bevy_ui::ui_node::ZIndex", "bevy_ui::widget::button::Button", "bevy_window::monitor::Monitor", "bevy_window::window::PrimaryWindow", "bevy_window::window::Window", "bevy_winit::cursor::CursorIcon", "server::Cube" ] } ``` Especially if you for example, are reading the GH examples because: ![image](https://github.com/user-attachments/assets/46c9c983-4bf9-4e70-9d6e-8de936505fbb) If you for example expand these things, due to the number of places bevy re-exports things you'll find it difficult to find the true path of something. i.e you'd probably be forgiven for writing a query (using the `client.rs` example): ```sh $ cargo run --example client -- bevy_pbr::mesh_material::MeshMaterial3d | jq { "error": { "code": -23402, "message": "Unknown component type: `bevy_pbr::mesh_material::MeshMaterial3d`" }, "id": 1, "jsonrpc": "2.0" } ``` which is where https://github.com/bevyengine/bevy/blob/8d9a00f5483b2ba28f40081759bd3d6f8b8a686d/crates/bevy_pbr/src/mesh_material.rs#L41 would lead you to believe it is... I've worked with bevy a lot, so it's no issue for me, but for others... ? ## Solution - Add some more docs, including a sample request (`json` and `rust`) ## Testing N/A --- ## Showcase N/A --------- Co-authored-by: Benjamin Brienen <[email protected]>
1 parent 3f19997 commit 33afd38

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

crates/bevy_remote/src/lib.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@
133133
//!
134134
//! `params`:
135135
//! - `data`:
136-
//! - `components` (optional): An array of [fully-qualified type names] of components to fetch.
136+
//! - `components` (optional): An array of [fully-qualified type names] of components to fetch,
137+
//! see _below_ example for a query to list all the type names in **your** project.
137138
//! - `option` (optional): An array of fully-qualified type names of components to fetch optionally.
138139
//! - `has` (optional): An array of fully-qualified type names of components whose presence will be
139140
//! reported as boolean values.
@@ -142,8 +143,8 @@
142143
//! on entities in order for them to be included in results.
143144
//! - `without` (optional): An array of fully-qualified type names of components that must *not* be
144145
//! present on entities in order for them to be included in results.
145-
//! - `strict` (optional): A flag to enable strict mode which will fail if any one of the
146-
//! components is not present or can not be reflected. Defaults to false.
146+
//! - `strict` (optional): A flag to enable strict mode which will fail if any one of the
147+
//! components is not present or can not be reflected. Defaults to false.
147148
//!
148149
//! `result`: An array, each of which is an object containing:
149150
//! - `entity`: The ID of a query-matching entity.
@@ -152,6 +153,8 @@
152153
//! - `has`: A map associating each type name from `has` to a boolean value indicating whether or not the
153154
//! entity has that component. If `has` was empty or omitted, this key will be omitted in the response.
154155
//!
156+
//!
157+
//!
155158
//! ### bevy/spawn
156159
//!
157160
//! Create a new entity with the provided components and return the resulting entity ID.
@@ -567,6 +570,26 @@ pub struct RemoteWatchingRequests(Vec<(BrpMessage, RemoteWatchingMethodSystemId)
567570
/// }
568571
/// }
569572
/// ```
573+
/// Or, to list all the fully-qualified type paths in **your** project, pass Null to the
574+
/// `params`.
575+
/// ```json
576+
/// {
577+
/// "jsonrpc": "2.0",
578+
/// "method": "bevy/list",
579+
/// "id": 0,
580+
/// "params": null
581+
///}
582+
///```
583+
///
584+
/// In Rust:
585+
/// ```ignore
586+
/// let req = BrpRequest {
587+
/// jsonrpc: "2.0".to_string(),
588+
/// method: BRP_LIST_METHOD.to_string(), // All the methods have consts
589+
/// id: Some(ureq::json!(0)),
590+
/// params: None,
591+
/// };
592+
/// ```
570593
#[derive(Debug, Serialize, Deserialize, Clone)]
571594
pub struct BrpRequest {
572595
/// This field is mandatory and must be set to `"2.0"` for the request to be accepted.

0 commit comments

Comments
 (0)