-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move definition of public_tx/choice and public_tx/proof to the public…
…_tx/vote mod
- Loading branch information
Showing
4 changed files
with
50 additions
and
53 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//! A public vote tx vote objects. | ||
use minicbor::{Decode, Encode}; | ||
|
||
use crate::uuid::Uuid; | ||
|
||
/// A public voting choice struct. | ||
#[derive(Debug, Clone, PartialEq)] | ||
pub struct Choice(pub u64); | ||
|
||
/// A public voting proof struct, CBOR `undefined`. | ||
#[derive(Debug, Clone, PartialEq)] | ||
pub struct Proof; | ||
|
||
/// A public voting proposal id struct. | ||
pub type PropId = Uuid; | ||
|
||
impl Decode<'_, ()> for Choice { | ||
fn decode(d: &mut minicbor::Decoder<'_>, (): &mut ()) -> Result<Self, minicbor::decode::Error> { | ||
let choice = d.u64()?; | ||
Ok(Self(choice)) | ||
} | ||
} | ||
|
||
impl Encode<()> for Choice { | ||
fn encode<W: minicbor::encode::Write>( | ||
&self, e: &mut minicbor::Encoder<W>, (): &mut (), | ||
) -> Result<(), minicbor::encode::Error<W::Error>> { | ||
self.0.encode(e, &mut ()) | ||
} | ||
} | ||
|
||
impl Decode<'_, ()> for Proof { | ||
fn decode(d: &mut minicbor::Decoder<'_>, (): &mut ()) -> Result<Self, minicbor::decode::Error> { | ||
d.undefined()?; | ||
Ok(Self) | ||
} | ||
} | ||
|
||
impl Encode<()> for Proof { | ||
fn encode<W: minicbor::encode::Write>( | ||
&self, e: &mut minicbor::Encoder<W>, (): &mut (), | ||
) -> Result<(), minicbor::encode::Error<W::Error>> { | ||
e.undefined()?; | ||
Ok(()) | ||
} | ||
} |