From f8f4463f776087dbaeddcf85524936c472858947 Mon Sep 17 00:00:00 2001 From: adz Date: Tue, 17 Dec 2024 19:07:34 +0100 Subject: [PATCH] Document id is not optional, prune flag can be derived as default --- aardvark-node/src/operation.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/aardvark-node/src/operation.rs b/aardvark-node/src/operation.rs index 0ae3fae..7b596bd 100644 --- a/aardvark-node/src/operation.rs +++ b/aardvark-node/src/operation.rs @@ -10,22 +10,26 @@ use crate::network::TextDocument; #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] pub struct AardvarkExtensions { - #[serde(rename = "p", skip_serializing_if = "Option::is_none")] - pub prune_flag: Option, - - #[serde(rename = "d", skip_serializing_if = "Option::is_none")] - pub document_id: Option, + #[serde( + rename = "p", + skip_serializing_if = "PruneFlag::is_not_set", + default = "PruneFlag::default" + )] + pub prune_flag: PruneFlag, + + #[serde(rename = "d")] + pub document_id: TextDocument, } impl Extension for AardvarkExtensions { fn extract(&self) -> Option { - self.prune_flag.clone() + Some(self.prune_flag.clone()) } } impl Extension for AardvarkExtensions { fn extract(&self) -> Option { - self.document_id.clone() + Some(self.document_id.clone()) } } @@ -69,8 +73,8 @@ pub async fn create_operation( .as_secs(); let extensions = AardvarkExtensions { - prune_flag: Some(PruneFlag::new(prune_flag)), - document_id: Some(document_id.clone()), + prune_flag: PruneFlag::new(prune_flag), + document_id: document_id.clone(), }; let mut header = Header {