-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathmod.rs
More file actions
38 lines (35 loc) · 1.3 KB
/
Copy pathmod.rs
File metadata and controls
38 lines (35 loc) · 1.3 KB
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
use crate::reduced_platform_state::v0::ReducedPlatformStateForSavingV0;
use crate::serialization::{PlatformSerializable, ReducedPlatformDeserializable};
use crate::ProtocolError;
use bincode::{config, Decode, Encode};
use derive_more::From;
use platform_version::version::PlatformVersion;
use platform_version::TryIntoPlatformVersioned;
use serde::{Deserialize, Serialize};
pub mod v0;
/// Reduced Platform State For Saving
#[derive(Clone, Debug, Encode, Decode)]
pub enum ReducedPlatformStateForSaving {
V0(ReducedPlatformStateForSavingV0),
}
impl ReducedPlatformDeserializable for ReducedPlatformStateForSaving {
fn versioned_deserialize(
data: &[u8],
platform_version: &PlatformVersion,
) -> Result<Self, ProtocolError>
where
Self: Sized,
{
let config = config::standard().with_big_endian().with_no_limit();
let reduced_platform_state_in_save_format: ReducedPlatformStateForSaving =
bincode::decode_from_slice(data, config)
.map_err(|e| {
ProtocolError::PlatformDeserializationError(format!(
"unable to deserialize ReducedPlatformStateForSaving: {}",
e
))
})?
.0;
Ok(reduced_platform_state_in_save_format)
}
}