Serialize node id as index
This commit is contained in:
parent
3d1bd0dc18
commit
85829519f7
|
@ -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