Skip to content

Commit d44e383

Browse files
committed
Introducing JsonBuffer type
Signed-off-by: Michael X. Grey <[email protected]>
1 parent 442c676 commit d44e383

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

src/buffer.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ pub use bufferable::*;
5252
mod manage_buffer;
5353
pub use manage_buffer::*;
5454

55+
#[cfg(feature = "diagram")]
56+
mod json_buffer;
57+
5558
/// A buffer is a special type of node within a workflow that is able to store
5659
/// and release data. When a session is finished, the buffered data from the
5760
/// session will be automatically cleared.

src/buffer/json_buffer.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (C) 2025 Open Source Robotics Foundation
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
use bevy_ecs::prelude::Entity;
19+
20+
use schemars::schema::Schema;
21+
22+
#[derive(Clone, Copy, Debug)]
23+
pub struct JsonBuffer {
24+
pub(crate) scope: Entity,
25+
pub(crate) source: Entity,
26+
pub(crate) interface: &'static dyn JsonInterface,
27+
}
28+
29+
pub(crate) trait JsonInterface {
30+
fn message_type(&self) -> &str;
31+
fn schema(&self) -> &Schema;
32+
}
33+
34+
impl<'a> std::fmt::Debug for &'a dyn JsonInterface {
35+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
36+
f
37+
.debug_struct("Message Properties")
38+
.field("type", &self.message_type())
39+
.field("schema", self.schema())
40+
.finish()
41+
}
42+
}

0 commit comments

Comments
 (0)