Skip to content

Commit

Permalink
fix serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
kmd-fl committed Sep 12, 2024
1 parent a9a7376 commit a779dba
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions particle-builtins/src/identify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,21 @@ pub struct NodeInfo {
pub air_version: &'static str,
pub spell_version: String,
pub allowed_effectors: Vec<String>,
// Note: this is Vec for Aqua's representation of an option
#[serde(serialize_with = "serialize_aqua_option")]
pub vm_info: Option<VmInfo>,
}

fn serialize_aqua_option<S>(value: &Option<VmInfo>, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
match value {
Some(vm_info) => serializer.collect_seq(&[vm_info]),
None => serializer.serialize_none(),
}
}

#[derive(Serialize, Clone, Debug)]
pub struct VmInfo {
// Public IP via which we can connect to the VM
Expand Down

0 comments on commit a779dba

Please sign in to comment.