1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use crate::host::scene_message::*;
use crate::host::error::*;
use crate::host::serialization_context::*;
pub use flo_scene_guest::guest_types::{SceneGuestMessage};
///
/// SceneGuestMessage is a cut-down version of SceneMessage: implicitly implement SceneMessage for every guest message
///
/// Unlike
///
impl<T: SceneGuestMessage> SceneMessage for T {
///
/// A string that identifies this message type uniquely when serializing
///
/// An error will occur if two types use the same name in the same process. We use `std::any::type_name()` by default
/// but this does not have a guaranteed format between Rust versions and may not be unique, so it's strongly recommended
/// to override this function to return a specific value.
///
fn message_type_name() -> String { <T as SceneGuestMessage>::message_type_name() }
///
/// With the 'json' feature turned on, converts this message to JSON format
///
#[cfg(feature="json")]
#[inline]
fn to_json(self) -> Result<serde_json::Value, SceneSendError<Self>> {
<T as SceneGuestMessage>::to_json(self)
}
///
/// With the 'json' feature turned on, creates an instance of this message from a JSON value
///
#[cfg(feature="json")]
#[inline]
fn from_json(value: &serde_json::Value) -> Result<Self, SceneSendError<()>> {
<T as SceneGuestMessage>::from_json(value)
}
///
/// Converts this message to the serialization format used for guest messages
///
#[cfg(any(feature="postcard", target_family="wasm"))]
#[inline]
fn to_guest_message(self, context: &impl SerializationContext) -> Result<Vec<u8>, SceneSendError<Self>> {
<T as SceneGuestMessage>::to_guest_message(self, context)
}
///
/// Converts this message from the serialization format used for guest messages
///
#[cfg(any(feature="postcard", target_family="wasm"))]
#[inline]
fn from_guest_message(value: &Vec<u8>, context: &impl SerializationContext) -> Result<Self, SceneSendError<()>> {
<T as SceneGuestMessage>::from_guest_message(value, context)
}
}