Serialize node id as index (#35)
This commit is contained in:
parent
fb1894fb8c
commit
21d648b7ff
|
@ -3,7 +3,7 @@ use std::any::Any;
|
|||
use serde::Serialize;
|
||||
|
||||
use netrunner::{
|
||||
node::NodeId,
|
||||
node::{serialize_node_id_as_index, NodeId},
|
||||
output_processors::{Record, RecordType, Runtime},
|
||||
settings::SimulationSettings,
|
||||
warding::SimulationState,
|
||||
|
@ -11,6 +11,7 @@ use netrunner::{
|
|||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct MixnodeState {
|
||||
#[serde(serialize_with = "serialize_node_id_as_index")]
|
||||
pub node_id: NodeId,
|
||||
pub step_id: usize,
|
||||
pub num_messages_broadcasted: usize,
|
||||
|
|
|
@ -189,3 +189,10 @@ impl NodeIdExt for NodeId {
|
|||
NodeId::new(bytes)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn serialize_node_id_as_index<S>(id: &NodeId, s: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: serde::Serializer,
|
||||
{
|
||||
s.serialize_u64(id.index() as u64)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue