Skip to main content

dpp/voting/votes/yes_no_vote/v0/
mod.rs

1#[cfg(feature = "json-conversion")]
2use crate::serialization::json_safe_fields;
3use crate::voting::vote_choices::yes_no_abstain_vote_choice::YesNoAbstainVoteChoice;
4use crate::ProtocolError;
5use bincode::{Decode, DecodeUntrusted, Encode};
6use platform_serialization_derive::{
7    PlatformDeserializeTrusted, PlatformDeserializeUntrusted, PlatformSerialize,
8};
9use platform_value::Identifier;
10#[cfg(feature = "serde-conversion")]
11use serde::{Deserialize, Serialize};
12
13/// Version 0 of a yes/no vote: the id of the poll answered and the answer. The poll's rule is
14/// not carried: it is in the poll's stored info, written when the poll opened.
15#[cfg_attr(feature = "json-conversion", json_safe_fields)]
16#[derive(
17    Debug,
18    Clone,
19    Encode,
20    Decode,
21    PlatformDeserializeTrusted,
22    PlatformDeserializeUntrusted,
23    PlatformSerialize,
24    PartialEq,
25    Eq,
26    DecodeUntrusted,
27)]
28#[cfg_attr(
29    feature = "serde-conversion",
30    derive(Serialize, Deserialize),
31    serde(rename_all = "camelCase")
32)]
33#[platform_serialize(unversioned)]
34pub struct YesNoVoteV0 {
35    /// The id of the poll answered (`YesNoVotePoll::unique_id`).
36    pub vote_poll_id: Identifier,
37    /// The answer.
38    pub vote_choice: YesNoAbstainVoteChoice,
39}