I want to impl CandidType for this struct without AtomicBool
supporting by candid
crate:
#[derive(Debug, Clone, Serialize, Deserialize)]
struct InnerSegmentMeta {
segment_id: SegmentId,
max_doc: u32,
deletes: Option<DeleteMeta>,
/// If you want to avoid the SegmentComponent::TempStore file to be covered by
/// garbage collection and deleted, set this to true. This is used during merge.
#[serde(skip)]
#[serde(default = "default_temp_store")]
pub(crate) include_temp_doc_store: Arc<AtomicBool>,
}
So i need to describe all of type details of the field of the struct in _ty()
function. But this way have a lot of duplications as segment_id
field, max_doc
field and deletes
field already had CandidType
implmentation:
impl candid::CandidType for InnerSegmentMeta {
fn _ty() -> candid::types::Type {
use candid::field;
use candid::types::{Field, TypeInner};
let segment_id_field = field! {segment_id: TypeInner::Text.into()};
let max_doc_field = field! {max_doc: TypeInner::Nat32.into()};
let deletes_field = field!{deletes: TypeInner::Opt(TypeInner::Vec(()))}
// let records = TypeInner::Record(vec![Field])
todo!()
}
fn idl_serialize<S>(&self, serializer: S) -> Result<(), S::Error>
where S: candid::types::Serializer {
todo!()
}
}
The only field
i need to implment is AtomicBool
. What is the best way to do this in rust? Thx in advance.