//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `voting/election/show`. Version: `0.1`.
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
///A board's tree head (RFC 9162 §2.1). A head is signed by being carried in a document the ballot box signs; whoever keeps a head keeps that whole document.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "BoardHead",
/// "description": "A board's tree head (RFC 9162 §2.1). A head is signed by being carried in a document the ballot box signs; whoever keeps a head keeps that whole document.",
/// "type": "object",
/// "required": [
/// "electionId",
/// "issuedAt",
/// "rootHash",
/// "treeSize"
/// ],
/// "properties": {
/// "electionId": {
/// "$ref": "#/definitions/ElectionId"
/// },
/// "issuedAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "rootHash": {
/// "description": "The RFC 9162 Merkle tree hash (SHA-256) of the first `treeSize` entries, as a multihash.",
/// "$ref": "#/definitions/DigestMultibase"
/// },
/// "treeSize": {
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct BoardHead {
#[serde(rename = "electionId")]
pub election_id: ElectionId,
#[serde(rename = "issuedAt")]
pub issued_at: ::chrono::DateTime<::chrono::offset::Utc>,
///The RFC 9162 Merkle tree hash (SHA-256) of the first `treeSize` entries, as a multihash.
#[serde(rename = "rootHash")]
pub root_hash: DigestMultibase,
#[serde(rename = "treeSize")]
pub tree_size: u64,
}
impl BoardHead {
pub fn builder() -> builder::BoardHead {
Default::default()
}
}
///`public`: anyone reads the board. `private`: the community, the auditors the manifest names and, for one cast's inclusion, the holder of its receipt (VTI-VOT-052).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "BoardVisibility",
/// "description": "`public`: anyone reads the board. `private`: the community, the auditors the manifest names and, for one cast's inclusion, the holder of its receipt (VTI-VOT-052).",
/// "type": "string",
/// "enum": [
/// "public",
/// "private"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum BoardVisibility {
#[serde(rename = "public")]
Public,
#[serde(rename = "private")]
Private,
}
impl ::std::fmt::Display for BoardVisibility {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Public => f.write_str("public"),
Self::Private => f.write_str("private"),
}
}
}
impl ::std::str::FromStr for BoardVisibility {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"public" => Ok(Self::Public),
"private" => Ok(Self::Private),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for BoardVisibility {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for BoardVisibility {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for BoardVisibility {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/**
A cryptographic digest as a multibase-encoded multihash — the encoding the W3C Verifiable Credentials Data Model 2.0 defines for `digestMultibase`, and the one `did:webvh` uses for its SCID and entry hashes.
Multihash carries the hash algorithm in-band, so the value is self-describing and the wire format survives an algorithm change without a schema revision; multibase does the same for the base encoding, so a verifier never infers base58 from base64url by context. A bare hex string or a `sha-256:`-style prefix hard-codes one algorithm into the wire contract and is non-conforming here.
This definition constrains the *encoding only*. What the digest is computed over is stated by each referencing field, because it differs legitimately: a digest over a JSON document is taken over its RFC 8785 (JCS) canonicalization, while a digest over an opaque artifact is taken over its bytes. A field whose input is a JSON document and which does not name a canonicalization is not reproducible.
Restricted to the two multibase headers W3C Controlled Identifiers 1.0 §2.4 normatively requires — `z` (base58btc) and `u` (base64url-no-pad). CID permits others but states that "interoperability is not guaranteed between implementations using such values", and a registry whose purpose is interoperability should not mint digests a conforming verifier may be unable to read. The alphabets are enforced rather than assumed: base58btc excludes 0, O, I and l, and an earlier permissive pattern let three published examples carry digests that were not valid base58 at all. base58btc is RECOMMENDED, for consistency with `did:key` and `did:webvh`.*/
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "DigestMultibase",
/// "description": "A cryptographic digest as a multibase-encoded multihash — the encoding the W3C Verifiable Credentials Data Model 2.0 defines for `digestMultibase`, and the one `did:webvh` uses for its SCID and entry hashes.\n\nMultihash carries the hash algorithm in-band, so the value is self-describing and the wire format survives an algorithm change without a schema revision; multibase does the same for the base encoding, so a verifier never infers base58 from base64url by context. A bare hex string or a `sha-256:`-style prefix hard-codes one algorithm into the wire contract and is non-conforming here.\n\nThis definition constrains the *encoding only*. What the digest is computed over is stated by each referencing field, because it differs legitimately: a digest over a JSON document is taken over its RFC 8785 (JCS) canonicalization, while a digest over an opaque artifact is taken over its bytes. A field whose input is a JSON document and which does not name a canonicalization is not reproducible.\n\nRestricted to the two multibase headers W3C Controlled Identifiers 1.0 §2.4 normatively requires — `z` (base58btc) and `u` (base64url-no-pad). CID permits others but states that \"interoperability is not guaranteed between implementations using such values\", and a registry whose purpose is interoperability should not mint digests a conforming verifier may be unable to read. The alphabets are enforced rather than assumed: base58btc excludes 0, O, I and l, and an earlier permissive pattern let three published examples carry digests that were not valid base58 at all. base58btc is RECOMMENDED, for consistency with `did:key` and `did:webvh`.",
/// "examples": [
/// "zQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR"
/// ],
/// "type": "string",
/// "minLength": 16,
/// "pattern": "^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct DigestMultibase(::std::string::String);
impl ::std::ops::Deref for DigestMultibase {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<DigestMultibase> for ::std::string::String {
fn from(value: DigestMultibase) -> Self {
value.0
}
}
impl ::std::str::FromStr for DigestMultibase {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 16usize {
return Err("shorter than 16 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err(
"doesn't match pattern \"^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$\"".into(),
);
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for DigestMultibase {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for DigestMultibase {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for DigestMultibase {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for DigestMultibase {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///An election's identifier, unique within its community. A closed alphabet: it appears in the ticket class label `voter/<electionId>` and is framed into every hash a cast is bound to.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ElectionId",
/// "description": "An election's identifier, unique within its community. A closed alphabet: it appears in the ticket class label `voter/<electionId>` and is framed into every hash a cast is bound to.",
/// "type": "string",
/// "pattern": "^[A-Za-z0-9._-]{1,128}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ElectionId(::std::string::String);
impl ::std::ops::Deref for ElectionId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ElectionId> for ::std::string::String {
fn from(value: ElectionId) -> Self {
value.0
}
}
impl ::std::str::FromStr for ElectionId {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^[A-Za-z0-9._-]{1,128}$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[A-Za-z0-9._-]{1,128}$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ElectionId {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ElectionId {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ElectionId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ElectionId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`ElectionState`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ElectionState",
/// "type": "string",
/// "enum": [
/// "registered",
/// "registration",
/// "voting",
/// "closed",
/// "tallied",
/// "cancelled"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum ElectionState {
#[serde(rename = "registered")]
Registered,
#[serde(rename = "registration")]
Registration,
#[serde(rename = "voting")]
Voting,
#[serde(rename = "closed")]
Closed,
#[serde(rename = "tallied")]
Tallied,
#[serde(rename = "cancelled")]
Cancelled,
}
impl ::std::fmt::Display for ElectionState {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Registered => f.write_str("registered"),
Self::Registration => f.write_str("registration"),
Self::Voting => f.write_str("voting"),
Self::Closed => f.write_str("closed"),
Self::Tallied => f.write_str("tallied"),
Self::Cancelled => f.write_str("cancelled"),
}
}
}
impl ::std::str::FromStr for ElectionState {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"registered" => Ok(Self::Registered),
"registration" => Ok(Self::Registration),
"voting" => Ok(Self::Voting),
"closed" => Ok(Self::Closed),
"tallied" => Ok(Self::Tallied),
"cancelled" => Ok(Self::Cancelled),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ElectionState {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ElectionState {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ElectionState {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///A ballot box's view of one election.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ElectionSummary",
/// "description": "A ballot box's view of one election.",
/// "type": "object",
/// "required": [
/// "ballotsAdmitted",
/// "community",
/// "electionId",
/// "head",
/// "manifestDigest",
/// "state"
/// ],
/// "properties": {
/// "ballotsAdmitted": {
/// "description": "Distinct tags with a counted ballot.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "community": {
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "electionId": {
/// "$ref": "#/definitions/ElectionId"
/// },
/// "head": {
/// "$ref": "#/definitions/BoardHead"
/// },
/// "manifestDigest": {
/// "$ref": "#/definitions/DigestMultibase"
/// },
/// "state": {
/// "$ref": "#/definitions/ElectionState"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ElectionSummary {
///Distinct tags with a counted ballot.
#[serde(rename = "ballotsAdmitted")]
pub ballots_admitted: u64,
pub community: ElectionSummaryCommunity,
#[serde(rename = "electionId")]
pub election_id: ElectionId,
pub head: BoardHead,
#[serde(rename = "manifestDigest")]
pub manifest_digest: DigestMultibase,
pub state: ElectionState,
}
impl ElectionSummary {
pub fn builder() -> builder::ElectionSummary {
Default::default()
}
}
///`ElectionSummaryCommunity`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ElectionSummaryCommunity(::std::string::String);
impl ::std::ops::Deref for ElectionSummaryCommunity {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ElectionSummaryCommunity> for ::std::string::String {
fn from(value: ElectionSummaryCommunity) -> Self {
value.0
}
}
impl ::std::str::FromStr for ElectionSummaryCommunity {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ElectionSummaryCommunity {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ElectionSummaryCommunity {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ElectionSummaryCommunity {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ElectionSummaryCommunity {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Ext",
/// "description": "Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.",
/// "type": "object",
/// "minProperties": 1,
/// "additionalProperties": true,
/// "propertyNames": {
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
/// }
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct Ext(pub ::std::collections::HashMap<ExtKey, ::serde_json::Value>);
impl ::std::ops::Deref for Ext {
type Target = ::std::collections::HashMap<ExtKey, ::serde_json::Value>;
fn deref(&self) -> &::std::collections::HashMap<ExtKey, ::serde_json::Value> {
&self.0
}
}
impl ::std::convert::From<Ext> for ::std::collections::HashMap<ExtKey, ::serde_json::Value> {
fn from(value: Ext) -> Self {
value.0
}
}
impl ::std::convert::From<::std::collections::HashMap<ExtKey, ::serde_json::Value>> for Ext {
fn from(value: ::std::collections::HashMap<ExtKey, ::serde_json::Value>) -> Self {
Self(value)
}
}
///`ExtKey`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ExtKey(::std::string::String);
impl ::std::ops::Deref for ExtKey {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ExtKey> for ::std::string::String {
fn from(value: ExtKey) -> Self {
value.0
}
}
impl ::std::str::FromStr for ExtKey {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ExtKey {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///A question or option key, unique within its manifest or question.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Key",
/// "description": "A question or option key, unique within its manifest or question.",
/// "type": "string",
/// "pattern": "^[A-Za-z0-9._-]{1,64}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct Key(::std::string::String);
impl ::std::ops::Deref for Key {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<Key> for ::std::string::String {
fn from(value: Key) -> Self {
value.0
}
}
impl ::std::str::FromStr for Key {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| ::regress::Regex::new("^[A-Za-z0-9._-]{1,64}$").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[A-Za-z0-9._-]{1,64}$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for Key {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for Key {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for Key {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for Key {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///What an election asks and how it is decided (VTI-VOT-010). Its digest (`manifestDigest`) is the SHA-256 multihash of its RFC 8785 (JCS) canonicalization, and every cast is bound to it (VTI-VOT-011).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Manifest",
/// "description": "What an election asks and how it is decided (VTI-VOT-010). Its digest (`manifestDigest`) is the SHA-256 multihash of its RFC 8785 (JCS) canonicalization, and every cast is bound to it (VTI-VOT-011).",
/// "type": "object",
/// "required": [
/// "allowEarlyClose",
/// "ballotBox",
/// "binding",
/// "board",
/// "community",
/// "electionId",
/// "questions",
/// "registrationOpens",
/// "resultsBeforeClose",
/// "revote",
/// "roll",
/// "secrecy",
/// "textReleaseThreshold",
/// "votingCloses",
/// "votingOpens"
/// ],
/// "properties": {
/// "allowEarlyClose": {
/// "type": "boolean"
/// },
/// "ballotBox": {
/// "description": "The DID of the voting service that holds the board.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "binding": {
/// "description": "Whether the community treats the result as deciding something; creating a binding election takes another administrator's consent (VTI-VOT-081).",
/// "type": "boolean"
/// },
/// "board": {
/// "type": "object",
/// "required": [
/// "auditors",
/// "visibility"
/// ],
/// "properties": {
/// "auditors": {
/// "type": "array",
/// "items": {
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "uniqueItems": true
/// },
/// "visibility": {
/// "$ref": "#/definitions/BoardVisibility"
/// }
/// },
/// "additionalProperties": false
/// },
/// "community": {
/// "description": "The community's DID.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "description": {
/// "type": "string",
/// "maxLength": 8192
/// },
/// "electionId": {
/// "$ref": "#/definitions/ElectionId"
/// },
/// "questions": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/Question"
/// },
/// "maxItems": 128,
/// "minItems": 1
/// },
/// "registrationOpens": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "resultsBeforeClose": {
/// "description": "Open elections only: whether running totals may be read while voting is open (VTI-VOT-061).",
/// "type": "boolean"
/// },
/// "revote": {
/// "$ref": "#/definitions/Revote"
/// },
/// "roll": {
/// "$ref": "#/definitions/RollRule"
/// },
/// "secrecy": {
/// "$ref": "#/definitions/SecrecyLevel"
/// },
/// "textReleaseThreshold": {
/// "description": "Counted ballots required before any text answer is disclosed (VTI-VOT-065).",
/// "type": "integer",
/// "minimum": 10.0
/// },
/// "title": {
/// "type": "string",
/// "maxLength": 512
/// },
/// "trustees": {
/// "$ref": "#/definitions/Trustees"
/// },
/// "votingCloses": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "votingOpens": {
/// "type": "string",
/// "format": "date-time"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Manifest {
#[serde(rename = "allowEarlyClose")]
pub allow_early_close: bool,
///The DID of the voting service that holds the board.
#[serde(rename = "ballotBox")]
pub ballot_box: ManifestBallotBox,
///Whether the community treats the result as deciding something; creating a binding election takes another administrator's consent (VTI-VOT-081).
pub binding: bool,
pub board: ManifestBoard,
///The community's DID.
pub community: ManifestCommunity,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub description: ::std::option::Option<ManifestDescription>,
#[serde(rename = "electionId")]
pub election_id: ElectionId,
pub questions: ::std::vec::Vec<Question>,
#[serde(rename = "registrationOpens")]
pub registration_opens: ::chrono::DateTime<::chrono::offset::Utc>,
///Open elections only: whether running totals may be read while voting is open (VTI-VOT-061).
#[serde(rename = "resultsBeforeClose")]
pub results_before_close: bool,
pub revote: Revote,
pub roll: RollRule,
pub secrecy: SecrecyLevel,
///Counted ballots required before any text answer is disclosed (VTI-VOT-065).
#[serde(rename = "textReleaseThreshold")]
pub text_release_threshold: i64,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub title: ::std::option::Option<ManifestTitle>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub trustees: ::std::option::Option<Trustees>,
#[serde(rename = "votingCloses")]
pub voting_closes: ::chrono::DateTime<::chrono::offset::Utc>,
#[serde(rename = "votingOpens")]
pub voting_opens: ::chrono::DateTime<::chrono::offset::Utc>,
}
impl Manifest {
pub fn builder() -> builder::Manifest {
Default::default()
}
}
///The DID of the voting service that holds the board.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The DID of the voting service that holds the board.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ManifestBallotBox(::std::string::String);
impl ::std::ops::Deref for ManifestBallotBox {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ManifestBallotBox> for ::std::string::String {
fn from(value: ManifestBallotBox) -> Self {
value.0
}
}
impl ::std::str::FromStr for ManifestBallotBox {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ManifestBallotBox {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ManifestBallotBox {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ManifestBallotBox {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ManifestBallotBox {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`ManifestBoard`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "auditors",
/// "visibility"
/// ],
/// "properties": {
/// "auditors": {
/// "type": "array",
/// "items": {
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "uniqueItems": true
/// },
/// "visibility": {
/// "$ref": "#/definitions/BoardVisibility"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ManifestBoard {
pub auditors: Vec<ManifestBoardAuditorsItem>,
pub visibility: BoardVisibility,
}
impl ManifestBoard {
pub fn builder() -> builder::ManifestBoard {
Default::default()
}
}
///`ManifestBoardAuditorsItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ManifestBoardAuditorsItem(::std::string::String);
impl ::std::ops::Deref for ManifestBoardAuditorsItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ManifestBoardAuditorsItem> for ::std::string::String {
fn from(value: ManifestBoardAuditorsItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for ManifestBoardAuditorsItem {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ManifestBoardAuditorsItem {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ManifestBoardAuditorsItem {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ManifestBoardAuditorsItem {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ManifestBoardAuditorsItem {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///The community's DID.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The community's DID.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ManifestCommunity(::std::string::String);
impl ::std::ops::Deref for ManifestCommunity {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ManifestCommunity> for ::std::string::String {
fn from(value: ManifestCommunity) -> Self {
value.0
}
}
impl ::std::str::FromStr for ManifestCommunity {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ManifestCommunity {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ManifestCommunity {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ManifestCommunity {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ManifestCommunity {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`ManifestDescription`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 8192
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ManifestDescription(::std::string::String);
impl ::std::ops::Deref for ManifestDescription {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ManifestDescription> for ::std::string::String {
fn from(value: ManifestDescription) -> Self {
value.0
}
}
impl ::std::str::FromStr for ManifestDescription {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 8192usize {
return Err("longer than 8192 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ManifestDescription {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ManifestDescription {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ManifestDescription {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ManifestDescription {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`ManifestTitle`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 512
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ManifestTitle(::std::string::String);
impl ::std::ops::Deref for ManifestTitle {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ManifestTitle> for ::std::string::String {
fn from(value: ManifestTitle) -> Self {
value.0
}
}
impl ::std::str::FromStr for ManifestTitle {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 512usize {
return Err("longer than 512 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ManifestTitle {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ManifestTitle {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ManifestTitle {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ManifestTitle {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///Reads one election at its ballot box: its state, manifest digest, admitted count and current head, and the manifest where the caller may read the board.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/voting/election/show/0.1",
/// "title": "Payload",
/// "description": "Reads one election at its ballot box: its state, manifest digest, admitted count and current head, and the manifest where the caller may read the board.",
/// "type": "object",
/// "required": [
/// "community",
/// "electionId"
/// ],
/// "properties": {
/// "community": {
/// "description": "The community's DID.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "electionId": {
/// "$ref": "#/definitions/ElectionId"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///The community's DID.
pub community: PayloadCommunity,
#[serde(rename = "electionId")]
pub election_id: ElectionId,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///The community's DID.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The community's DID.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadCommunity(::std::string::String);
impl ::std::ops::Deref for PayloadCommunity {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadCommunity> for ::std::string::String {
fn from(value: PayloadCommunity) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadCommunity {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadCommunity {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for PayloadCommunity {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for PayloadCommunity {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for PayloadCommunity {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///One question. Tagged union over `type`.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Question",
/// "description": "One question. Tagged union over `type`.",
/// "oneOf": [
/// {
/// "title": "ChoiceQuestion",
/// "description": "Select between `minSelections` and `maxSelections` of `options`. A yes/no/abstain motion is a choice of exactly one of three.",
/// "type": "object",
/// "required": [
/// "key",
/// "maxSelections",
/// "minSelections",
/// "optional",
/// "options",
/// "type"
/// ],
/// "properties": {
/// "key": {
/// "$ref": "#/definitions/Key"
/// },
/// "maxSelections": {
/// "type": "integer",
/// "minimum": 1.0
/// },
/// "minSelections": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "optional": {
/// "type": "boolean"
/// },
/// "options": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/QuestionOption"
/// },
/// "maxItems": 256,
/// "minItems": 2
/// },
/// "text": {
/// "type": "string",
/// "maxLength": 2048
/// },
/// "type": {
/// "const": "choice"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "RankingQuestion",
/// "description": "Order `options`; a ballot ranks every option or, when `partial` is true, a prefix of them.",
/// "type": "object",
/// "required": [
/// "key",
/// "optional",
/// "options",
/// "partial",
/// "type"
/// ],
/// "properties": {
/// "key": {
/// "$ref": "#/definitions/Key"
/// },
/// "optional": {
/// "type": "boolean"
/// },
/// "options": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/QuestionOption"
/// },
/// "maxItems": 64,
/// "minItems": 2
/// },
/// "partial": {
/// "type": "boolean"
/// },
/// "text": {
/// "type": "string",
/// "maxLength": 2048
/// },
/// "type": {
/// "const": "ranking"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "ScoreQuestion",
/// "description": "Give each option an integer score within [min, max].",
/// "type": "object",
/// "required": [
/// "key",
/// "max",
/// "min",
/// "optional",
/// "options",
/// "type"
/// ],
/// "properties": {
/// "key": {
/// "$ref": "#/definitions/Key"
/// },
/// "max": {
/// "type": "integer"
/// },
/// "min": {
/// "type": "integer"
/// },
/// "optional": {
/// "type": "boolean"
/// },
/// "options": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/QuestionOption"
/// },
/// "maxItems": 256,
/// "minItems": 1
/// },
/// "text": {
/// "type": "string",
/// "maxLength": 2048
/// },
/// "type": {
/// "const": "score"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "TextQuestion",
/// "description": "Free text of at most `maxLength` characters.",
/// "type": "object",
/// "required": [
/// "key",
/// "maxLength",
/// "optional",
/// "type"
/// ],
/// "properties": {
/// "key": {
/// "$ref": "#/definitions/Key"
/// },
/// "maxLength": {
/// "type": "integer",
/// "maximum": 4096.0,
/// "minimum": 1.0
/// },
/// "optional": {
/// "type": "boolean"
/// },
/// "text": {
/// "type": "string",
/// "maxLength": 2048
/// },
/// "type": {
/// "const": "text"
/// }
/// },
/// "additionalProperties": false
/// }
/// ]
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(tag = "type", deny_unknown_fields)]
#[non_exhaustive]
pub enum Question {
/**
ChoiceQuestion
Select between `minSelections` and `maxSelections` of `options`. A yes/no/abstain motion is a choice of exactly one of three.*/
#[serde(rename = "choice")]
Choice {
key: Key,
#[serde(rename = "maxSelections")]
max_selections: ::std::num::NonZeroU64,
#[serde(rename = "minSelections")]
min_selections: u64,
optional: bool,
options: ::std::vec::Vec<QuestionOption>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
text: ::std::option::Option<QuestionText>,
},
/**
RankingQuestion
Order `options`; a ballot ranks every option or, when `partial` is true, a prefix of them.*/
#[serde(rename = "ranking")]
Ranking {
key: Key,
optional: bool,
options: ::std::vec::Vec<QuestionOption>,
partial: bool,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
text: ::std::option::Option<QuestionText>,
},
/**
ScoreQuestion
Give each option an integer score within [min, max].*/
#[serde(rename = "score")]
Score {
key: Key,
max: i64,
min: i64,
optional: bool,
options: ::std::vec::Vec<QuestionOption>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
text: ::std::option::Option<QuestionText>,
},
/**
TextQuestion
Free text of at most `maxLength` characters.*/
#[serde(rename = "text")]
Text {
key: Key,
#[serde(rename = "maxLength")]
max_length: ::std::num::NonZeroU64,
optional: bool,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
text: ::std::option::Option<QuestionText>,
},
}
///`QuestionOption`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "QuestionOption",
/// "type": "object",
/// "required": [
/// "key"
/// ],
/// "properties": {
/// "key": {
/// "$ref": "#/definitions/Key"
/// },
/// "label": {
/// "description": "Display text. Absent from a manifest registered with a ballot box that holds no question text (VTI-VOT-014).",
/// "type": "string",
/// "maxLength": 512
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct QuestionOption {
pub key: Key,
///Display text. Absent from a manifest registered with a ballot box that holds no question text (VTI-VOT-014).
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub label: ::std::option::Option<QuestionOptionLabel>,
}
impl QuestionOption {
pub fn builder() -> builder::QuestionOption {
Default::default()
}
}
///Display text. Absent from a manifest registered with a ballot box that holds no question text (VTI-VOT-014).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Display text. Absent from a manifest registered with a ballot box that holds no question text (VTI-VOT-014).",
/// "type": "string",
/// "maxLength": 512
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct QuestionOptionLabel(::std::string::String);
impl ::std::ops::Deref for QuestionOptionLabel {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<QuestionOptionLabel> for ::std::string::String {
fn from(value: QuestionOptionLabel) -> Self {
value.0
}
}
impl ::std::str::FromStr for QuestionOptionLabel {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 512usize {
return Err("longer than 512 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for QuestionOptionLabel {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for QuestionOptionLabel {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for QuestionOptionLabel {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for QuestionOptionLabel {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`QuestionText`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 2048
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct QuestionText(::std::string::String);
impl ::std::ops::Deref for QuestionText {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<QuestionText> for ::std::string::String {
fn from(value: QuestionText) -> Self {
value.0
}
}
impl ::std::str::FromStr for QuestionText {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for QuestionText {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for QuestionText {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for QuestionText {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for QuestionText {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`Response`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "type": "object",
/// "required": [
/// "election"
/// ],
/// "properties": {
/// "election": {
/// "$ref": "#/definitions/ElectionSummary"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "manifest": {
/// "description": "The registered manifest, exactly as registered. Present when the board is public or the caller may read the private board.",
/// "$ref": "#/definitions/Manifest"
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
pub election: ElectionSummary,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///The registered manifest, exactly as registered. Present when the board is public or the caller may read the private board.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub manifest: ::std::option::Option<Manifest>,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///What a later, different ballot under one ticket does: `replace` the earlier one, or be refused (`refuse`) (VTI-VOT-041).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Revote",
/// "description": "What a later, different ballot under one ticket does: `replace` the earlier one, or be refused (`refuse`) (VTI-VOT-041).",
/// "type": "string",
/// "enum": [
/// "replace",
/// "refuse"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum Revote {
#[serde(rename = "replace")]
Replace,
#[serde(rename = "refuse")]
Refuse,
}
impl ::std::fmt::Display for Revote {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Replace => f.write_str("replace"),
Self::Refuse => f.write_str("refuse"),
}
}
}
impl ::std::str::FromStr for Revote {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"replace" => Ok(Self::Replace),
"refuse" => Ok(Self::Refuse),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for Revote {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for Revote {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for Revote {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Who may be issued a ticket (VTI-VOT-021): the community's active members, its active members and the parties `listed` names, or only the parties `listed` names.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "RollRule",
/// "description": "Who may be issued a ticket (VTI-VOT-021): the community's active members, its active members and the parties `listed` names, or only the parties `listed` names.",
/// "type": "object",
/// "required": [
/// "rule"
/// ],
/// "properties": {
/// "listed": {
/// "type": "array",
/// "items": {
/// "description": "A DID enfranchised by name.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "uniqueItems": true
/// },
/// "rule": {
/// "type": "string",
/// "enum": [
/// "members",
/// "membersAndListed",
/// "listed"
/// ]
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct RollRule {
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub listed: ::std::option::Option<Vec<RollRuleListedItem>>,
pub rule: RollRuleRule,
}
impl RollRule {
pub fn builder() -> builder::RollRule {
Default::default()
}
}
///A DID enfranchised by name.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "A DID enfranchised by name.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct RollRuleListedItem(::std::string::String);
impl ::std::ops::Deref for RollRuleListedItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<RollRuleListedItem> for ::std::string::String {
fn from(value: RollRuleListedItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for RollRuleListedItem {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for RollRuleListedItem {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for RollRuleListedItem {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for RollRuleListedItem {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for RollRuleListedItem {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`RollRuleRule`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "enum": [
/// "members",
/// "membersAndListed",
/// "listed"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum RollRuleRule {
#[serde(rename = "members")]
Members,
#[serde(rename = "membersAndListed")]
MembersAndListed,
#[serde(rename = "listed")]
Listed,
}
impl ::std::fmt::Display for RollRuleRule {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Members => f.write_str("members"),
Self::MembersAndListed => f.write_str("membersAndListed"),
Self::Listed => f.write_str("listed"),
}
}
}
impl ::std::str::FromStr for RollRuleRule {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"members" => Ok(Self::Members),
"membersAndListed" => Ok(Self::MembersAndListed),
"listed" => Ok(Self::Listed),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for RollRuleRule {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for RollRuleRule {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for RollRuleRule {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///`open`: ballots are recorded on the board as cast. `sealed`: ballots are encrypted to a jointly generated election key and decrypted after voting closes. `talliedEncrypted`: ballots are encrypted and only the totals are ever decrypted (VTI-VOT-060). The encrypted levels are cast with `voting/ballot/cast-encrypted/0.1`, under an election key the trustees generate with `voting/trustees/*` (CONVENTIONS §9).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "SecrecyLevel",
/// "description": "`open`: ballots are recorded on the board as cast. `sealed`: ballots are encrypted to a jointly generated election key and decrypted after voting closes. `talliedEncrypted`: ballots are encrypted and only the totals are ever decrypted (VTI-VOT-060). The encrypted levels are cast with `voting/ballot/cast-encrypted/0.1`, under an election key the trustees generate with `voting/trustees/*` (CONVENTIONS §9).",
/// "type": "string",
/// "enum": [
/// "open",
/// "sealed",
/// "talliedEncrypted"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum SecrecyLevel {
#[serde(rename = "open")]
Open,
#[serde(rename = "sealed")]
Sealed,
#[serde(rename = "talliedEncrypted")]
TalliedEncrypted,
}
impl ::std::fmt::Display for SecrecyLevel {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Open => f.write_str("open"),
Self::Sealed => f.write_str("sealed"),
Self::TalliedEncrypted => f.write_str("talliedEncrypted"),
}
}
}
impl ::std::str::FromStr for SecrecyLevel {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"open" => Ok(Self::Open),
"sealed" => Ok(Self::Sealed),
"talliedEncrypted" => Ok(Self::TalliedEncrypted),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for SecrecyLevel {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for SecrecyLevel {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for SecrecyLevel {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///The trustees of a sealed or tallied-encrypted election and the number of them decryption needs (VTI-VOT-062). Neither the community nor the ballot box may be one.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Trustees",
/// "description": "The trustees of a sealed or tallied-encrypted election and the number of them decryption needs (VTI-VOT-062). Neither the community nor the ballot box may be one.",
/// "type": "object",
/// "required": [
/// "dids",
/// "threshold"
/// ],
/// "properties": {
/// "dids": {
/// "type": "array",
/// "items": {
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "minItems": 2,
/// "uniqueItems": true
/// },
/// "threshold": {
/// "type": "integer",
/// "minimum": 2.0
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Trustees {
pub dids: Vec<TrusteesDidsItem>,
pub threshold: i64,
}
impl Trustees {
pub fn builder() -> builder::Trustees {
Default::default()
}
}
///`TrusteesDidsItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct TrusteesDidsItem(::std::string::String);
impl ::std::ops::Deref for TrusteesDidsItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<TrusteesDidsItem> for ::std::string::String {
fn from(value: TrusteesDidsItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for TrusteesDidsItem {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for TrusteesDidsItem {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for TrusteesDidsItem {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for TrusteesDidsItem {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for TrusteesDidsItem {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct BoardHead {
election_id: ::std::result::Result<super::ElectionId, ::std::string::String>,
issued_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
root_hash: ::std::result::Result<super::DigestMultibase, ::std::string::String>,
tree_size: ::std::result::Result<u64, ::std::string::String>,
}
impl ::std::default::Default for BoardHead {
fn default() -> Self {
Self {
election_id: Err("no value supplied for election_id".to_string()),
issued_at: Err("no value supplied for issued_at".to_string()),
root_hash: Err("no value supplied for root_hash".to_string()),
tree_size: Err("no value supplied for tree_size".to_string()),
}
}
}
impl BoardHead {
pub fn election_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElectionId>,
T::Error: ::std::fmt::Display,
{
self.election_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for election_id: {e}"));
self
}
pub fn issued_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.issued_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for issued_at: {e}"));
self
}
pub fn root_hash<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::DigestMultibase>,
T::Error: ::std::fmt::Display,
{
self.root_hash = value
.try_into()
.map_err(|e| format!("error converting supplied value for root_hash: {e}"));
self
}
pub fn tree_size<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.tree_size = value
.try_into()
.map_err(|e| format!("error converting supplied value for tree_size: {e}"));
self
}
}
impl ::std::convert::TryFrom<BoardHead> for super::BoardHead {
type Error = super::error::ConversionError;
fn try_from(
value: BoardHead,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
election_id: value.election_id?,
issued_at: value.issued_at?,
root_hash: value.root_hash?,
tree_size: value.tree_size?,
})
}
}
impl ::std::convert::From<super::BoardHead> for BoardHead {
fn from(value: super::BoardHead) -> Self {
Self {
election_id: Ok(value.election_id),
issued_at: Ok(value.issued_at),
root_hash: Ok(value.root_hash),
tree_size: Ok(value.tree_size),
}
}
}
#[derive(Clone, Debug)]
pub struct ElectionSummary {
ballots_admitted: ::std::result::Result<u64, ::std::string::String>,
community: ::std::result::Result<super::ElectionSummaryCommunity, ::std::string::String>,
election_id: ::std::result::Result<super::ElectionId, ::std::string::String>,
head: ::std::result::Result<super::BoardHead, ::std::string::String>,
manifest_digest: ::std::result::Result<super::DigestMultibase, ::std::string::String>,
state: ::std::result::Result<super::ElectionState, ::std::string::String>,
}
impl ::std::default::Default for ElectionSummary {
fn default() -> Self {
Self {
ballots_admitted: Err("no value supplied for ballots_admitted".to_string()),
community: Err("no value supplied for community".to_string()),
election_id: Err("no value supplied for election_id".to_string()),
head: Err("no value supplied for head".to_string()),
manifest_digest: Err("no value supplied for manifest_digest".to_string()),
state: Err("no value supplied for state".to_string()),
}
}
}
impl ElectionSummary {
pub fn ballots_admitted<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.ballots_admitted = value
.try_into()
.map_err(|e| format!("error converting supplied value for ballots_admitted: {e}"));
self
}
pub fn community<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElectionSummaryCommunity>,
T::Error: ::std::fmt::Display,
{
self.community = value
.try_into()
.map_err(|e| format!("error converting supplied value for community: {e}"));
self
}
pub fn election_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElectionId>,
T::Error: ::std::fmt::Display,
{
self.election_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for election_id: {e}"));
self
}
pub fn head<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::BoardHead>,
T::Error: ::std::fmt::Display,
{
self.head = value
.try_into()
.map_err(|e| format!("error converting supplied value for head: {e}"));
self
}
pub fn manifest_digest<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::DigestMultibase>,
T::Error: ::std::fmt::Display,
{
self.manifest_digest = value
.try_into()
.map_err(|e| format!("error converting supplied value for manifest_digest: {e}"));
self
}
pub fn state<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElectionState>,
T::Error: ::std::fmt::Display,
{
self.state = value
.try_into()
.map_err(|e| format!("error converting supplied value for state: {e}"));
self
}
}
impl ::std::convert::TryFrom<ElectionSummary> for super::ElectionSummary {
type Error = super::error::ConversionError;
fn try_from(
value: ElectionSummary,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
ballots_admitted: value.ballots_admitted?,
community: value.community?,
election_id: value.election_id?,
head: value.head?,
manifest_digest: value.manifest_digest?,
state: value.state?,
})
}
}
impl ::std::convert::From<super::ElectionSummary> for ElectionSummary {
fn from(value: super::ElectionSummary) -> Self {
Self {
ballots_admitted: Ok(value.ballots_admitted),
community: Ok(value.community),
election_id: Ok(value.election_id),
head: Ok(value.head),
manifest_digest: Ok(value.manifest_digest),
state: Ok(value.state),
}
}
}
#[derive(Clone, Debug)]
pub struct Manifest {
allow_early_close: ::std::result::Result<bool, ::std::string::String>,
ballot_box: ::std::result::Result<super::ManifestBallotBox, ::std::string::String>,
binding: ::std::result::Result<bool, ::std::string::String>,
board: ::std::result::Result<super::ManifestBoard, ::std::string::String>,
community: ::std::result::Result<super::ManifestCommunity, ::std::string::String>,
description: ::std::result::Result<
::std::option::Option<super::ManifestDescription>,
::std::string::String,
>,
election_id: ::std::result::Result<super::ElectionId, ::std::string::String>,
questions: ::std::result::Result<::std::vec::Vec<super::Question>, ::std::string::String>,
registration_opens:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
results_before_close: ::std::result::Result<bool, ::std::string::String>,
revote: ::std::result::Result<super::Revote, ::std::string::String>,
roll: ::std::result::Result<super::RollRule, ::std::string::String>,
secrecy: ::std::result::Result<super::SecrecyLevel, ::std::string::String>,
text_release_threshold: ::std::result::Result<i64, ::std::string::String>,
title: ::std::result::Result<
::std::option::Option<super::ManifestTitle>,
::std::string::String,
>,
trustees:
::std::result::Result<::std::option::Option<super::Trustees>, ::std::string::String>,
voting_closes:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
voting_opens:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
}
impl ::std::default::Default for Manifest {
fn default() -> Self {
Self {
allow_early_close: Err("no value supplied for allow_early_close".to_string()),
ballot_box: Err("no value supplied for ballot_box".to_string()),
binding: Err("no value supplied for binding".to_string()),
board: Err("no value supplied for board".to_string()),
community: Err("no value supplied for community".to_string()),
description: Ok(Default::default()),
election_id: Err("no value supplied for election_id".to_string()),
questions: Err("no value supplied for questions".to_string()),
registration_opens: Err("no value supplied for registration_opens".to_string()),
results_before_close: Err("no value supplied for results_before_close".to_string()),
revote: Err("no value supplied for revote".to_string()),
roll: Err("no value supplied for roll".to_string()),
secrecy: Err("no value supplied for secrecy".to_string()),
text_release_threshold: Err(
"no value supplied for text_release_threshold".to_string()
),
title: Ok(Default::default()),
trustees: Ok(Default::default()),
voting_closes: Err("no value supplied for voting_closes".to_string()),
voting_opens: Err("no value supplied for voting_opens".to_string()),
}
}
}
impl Manifest {
pub fn allow_early_close<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.allow_early_close = value
.try_into()
.map_err(|e| format!("error converting supplied value for allow_early_close: {e}"));
self
}
pub fn ballot_box<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ManifestBallotBox>,
T::Error: ::std::fmt::Display,
{
self.ballot_box = value
.try_into()
.map_err(|e| format!("error converting supplied value for ballot_box: {e}"));
self
}
pub fn binding<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.binding = value
.try_into()
.map_err(|e| format!("error converting supplied value for binding: {e}"));
self
}
pub fn board<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ManifestBoard>,
T::Error: ::std::fmt::Display,
{
self.board = value
.try_into()
.map_err(|e| format!("error converting supplied value for board: {e}"));
self
}
pub fn community<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ManifestCommunity>,
T::Error: ::std::fmt::Display,
{
self.community = value
.try_into()
.map_err(|e| format!("error converting supplied value for community: {e}"));
self
}
pub fn description<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ManifestDescription>>,
T::Error: ::std::fmt::Display,
{
self.description = value
.try_into()
.map_err(|e| format!("error converting supplied value for description: {e}"));
self
}
pub fn election_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElectionId>,
T::Error: ::std::fmt::Display,
{
self.election_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for election_id: {e}"));
self
}
pub fn questions<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::Question>>,
T::Error: ::std::fmt::Display,
{
self.questions = value
.try_into()
.map_err(|e| format!("error converting supplied value for questions: {e}"));
self
}
pub fn registration_opens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.registration_opens = value.try_into().map_err(|e| {
format!("error converting supplied value for registration_opens: {e}")
});
self
}
pub fn results_before_close<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.results_before_close = value.try_into().map_err(|e| {
format!("error converting supplied value for results_before_close: {e}")
});
self
}
pub fn revote<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Revote>,
T::Error: ::std::fmt::Display,
{
self.revote = value
.try_into()
.map_err(|e| format!("error converting supplied value for revote: {e}"));
self
}
pub fn roll<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::RollRule>,
T::Error: ::std::fmt::Display,
{
self.roll = value
.try_into()
.map_err(|e| format!("error converting supplied value for roll: {e}"));
self
}
pub fn secrecy<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::SecrecyLevel>,
T::Error: ::std::fmt::Display,
{
self.secrecy = value
.try_into()
.map_err(|e| format!("error converting supplied value for secrecy: {e}"));
self
}
pub fn text_release_threshold<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<i64>,
T::Error: ::std::fmt::Display,
{
self.text_release_threshold = value.try_into().map_err(|e| {
format!("error converting supplied value for text_release_threshold: {e}")
});
self
}
pub fn title<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ManifestTitle>>,
T::Error: ::std::fmt::Display,
{
self.title = value
.try_into()
.map_err(|e| format!("error converting supplied value for title: {e}"));
self
}
pub fn trustees<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Trustees>>,
T::Error: ::std::fmt::Display,
{
self.trustees = value
.try_into()
.map_err(|e| format!("error converting supplied value for trustees: {e}"));
self
}
pub fn voting_closes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.voting_closes = value
.try_into()
.map_err(|e| format!("error converting supplied value for voting_closes: {e}"));
self
}
pub fn voting_opens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.voting_opens = value
.try_into()
.map_err(|e| format!("error converting supplied value for voting_opens: {e}"));
self
}
}
impl ::std::convert::TryFrom<Manifest> for super::Manifest {
type Error = super::error::ConversionError;
fn try_from(value: Manifest) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
allow_early_close: value.allow_early_close?,
ballot_box: value.ballot_box?,
binding: value.binding?,
board: value.board?,
community: value.community?,
description: value.description?,
election_id: value.election_id?,
questions: value.questions?,
registration_opens: value.registration_opens?,
results_before_close: value.results_before_close?,
revote: value.revote?,
roll: value.roll?,
secrecy: value.secrecy?,
text_release_threshold: value.text_release_threshold?,
title: value.title?,
trustees: value.trustees?,
voting_closes: value.voting_closes?,
voting_opens: value.voting_opens?,
})
}
}
impl ::std::convert::From<super::Manifest> for Manifest {
fn from(value: super::Manifest) -> Self {
Self {
allow_early_close: Ok(value.allow_early_close),
ballot_box: Ok(value.ballot_box),
binding: Ok(value.binding),
board: Ok(value.board),
community: Ok(value.community),
description: Ok(value.description),
election_id: Ok(value.election_id),
questions: Ok(value.questions),
registration_opens: Ok(value.registration_opens),
results_before_close: Ok(value.results_before_close),
revote: Ok(value.revote),
roll: Ok(value.roll),
secrecy: Ok(value.secrecy),
text_release_threshold: Ok(value.text_release_threshold),
title: Ok(value.title),
trustees: Ok(value.trustees),
voting_closes: Ok(value.voting_closes),
voting_opens: Ok(value.voting_opens),
}
}
}
#[derive(Clone, Debug)]
pub struct ManifestBoard {
auditors:
::std::result::Result<Vec<super::ManifestBoardAuditorsItem>, ::std::string::String>,
visibility: ::std::result::Result<super::BoardVisibility, ::std::string::String>,
}
impl ::std::default::Default for ManifestBoard {
fn default() -> Self {
Self {
auditors: Err("no value supplied for auditors".to_string()),
visibility: Err("no value supplied for visibility".to_string()),
}
}
}
impl ManifestBoard {
pub fn auditors<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<Vec<super::ManifestBoardAuditorsItem>>,
T::Error: ::std::fmt::Display,
{
self.auditors = value
.try_into()
.map_err(|e| format!("error converting supplied value for auditors: {e}"));
self
}
pub fn visibility<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::BoardVisibility>,
T::Error: ::std::fmt::Display,
{
self.visibility = value
.try_into()
.map_err(|e| format!("error converting supplied value for visibility: {e}"));
self
}
}
impl ::std::convert::TryFrom<ManifestBoard> for super::ManifestBoard {
type Error = super::error::ConversionError;
fn try_from(
value: ManifestBoard,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
auditors: value.auditors?,
visibility: value.visibility?,
})
}
}
impl ::std::convert::From<super::ManifestBoard> for ManifestBoard {
fn from(value: super::ManifestBoard) -> Self {
Self {
auditors: Ok(value.auditors),
visibility: Ok(value.visibility),
}
}
}
#[derive(Clone, Debug)]
pub struct Payload {
community: ::std::result::Result<super::PayloadCommunity, ::std::string::String>,
election_id: ::std::result::Result<super::ElectionId, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
community: Err("no value supplied for community".to_string()),
election_id: Err("no value supplied for election_id".to_string()),
ext: Ok(Default::default()),
}
}
}
impl Payload {
pub fn community<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadCommunity>,
T::Error: ::std::fmt::Display,
{
self.community = value
.try_into()
.map_err(|e| format!("error converting supplied value for community: {e}"));
self
}
pub fn election_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElectionId>,
T::Error: ::std::fmt::Display,
{
self.election_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for election_id: {e}"));
self
}
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
}
impl ::std::convert::TryFrom<Payload> for super::Payload {
type Error = super::error::ConversionError;
fn try_from(value: Payload) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
community: value.community?,
election_id: value.election_id?,
ext: value.ext?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
community: Ok(value.community),
election_id: Ok(value.election_id),
ext: Ok(value.ext),
}
}
}
#[derive(Clone, Debug)]
pub struct QuestionOption {
key: ::std::result::Result<super::Key, ::std::string::String>,
label: ::std::result::Result<
::std::option::Option<super::QuestionOptionLabel>,
::std::string::String,
>,
}
impl ::std::default::Default for QuestionOption {
fn default() -> Self {
Self {
key: Err("no value supplied for key".to_string()),
label: Ok(Default::default()),
}
}
}
impl QuestionOption {
pub fn key<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Key>,
T::Error: ::std::fmt::Display,
{
self.key = value
.try_into()
.map_err(|e| format!("error converting supplied value for key: {e}"));
self
}
pub fn label<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::QuestionOptionLabel>>,
T::Error: ::std::fmt::Display,
{
self.label = value
.try_into()
.map_err(|e| format!("error converting supplied value for label: {e}"));
self
}
}
impl ::std::convert::TryFrom<QuestionOption> for super::QuestionOption {
type Error = super::error::ConversionError;
fn try_from(
value: QuestionOption,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
key: value.key?,
label: value.label?,
})
}
}
impl ::std::convert::From<super::QuestionOption> for QuestionOption {
fn from(value: super::QuestionOption) -> Self {
Self {
key: Ok(value.key),
label: Ok(value.label),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
election: ::std::result::Result<super::ElectionSummary, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
manifest:
::std::result::Result<::std::option::Option<super::Manifest>, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
election: Err("no value supplied for election".to_string()),
ext: Ok(Default::default()),
manifest: Ok(Default::default()),
}
}
}
impl Response {
pub fn election<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElectionSummary>,
T::Error: ::std::fmt::Display,
{
self.election = value
.try_into()
.map_err(|e| format!("error converting supplied value for election: {e}"));
self
}
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
pub fn manifest<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Manifest>>,
T::Error: ::std::fmt::Display,
{
self.manifest = value
.try_into()
.map_err(|e| format!("error converting supplied value for manifest: {e}"));
self
}
}
impl ::std::convert::TryFrom<Response> for super::Response {
type Error = super::error::ConversionError;
fn try_from(value: Response) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
election: value.election?,
ext: value.ext?,
manifest: value.manifest?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
election: Ok(value.election),
ext: Ok(value.ext),
manifest: Ok(value.manifest),
}
}
}
#[derive(Clone, Debug)]
pub struct RollRule {
listed: ::std::result::Result<
::std::option::Option<Vec<super::RollRuleListedItem>>,
::std::string::String,
>,
rule: ::std::result::Result<super::RollRuleRule, ::std::string::String>,
}
impl ::std::default::Default for RollRule {
fn default() -> Self {
Self {
listed: Ok(Default::default()),
rule: Err("no value supplied for rule".to_string()),
}
}
}
impl RollRule {
pub fn listed<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<Vec<super::RollRuleListedItem>>>,
T::Error: ::std::fmt::Display,
{
self.listed = value
.try_into()
.map_err(|e| format!("error converting supplied value for listed: {e}"));
self
}
pub fn rule<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::RollRuleRule>,
T::Error: ::std::fmt::Display,
{
self.rule = value
.try_into()
.map_err(|e| format!("error converting supplied value for rule: {e}"));
self
}
}
impl ::std::convert::TryFrom<RollRule> for super::RollRule {
type Error = super::error::ConversionError;
fn try_from(value: RollRule) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
listed: value.listed?,
rule: value.rule?,
})
}
}
impl ::std::convert::From<super::RollRule> for RollRule {
fn from(value: super::RollRule) -> Self {
Self {
listed: Ok(value.listed),
rule: Ok(value.rule),
}
}
}
#[derive(Clone, Debug)]
pub struct Trustees {
dids: ::std::result::Result<Vec<super::TrusteesDidsItem>, ::std::string::String>,
threshold: ::std::result::Result<i64, ::std::string::String>,
}
impl ::std::default::Default for Trustees {
fn default() -> Self {
Self {
dids: Err("no value supplied for dids".to_string()),
threshold: Err("no value supplied for threshold".to_string()),
}
}
}
impl Trustees {
pub fn dids<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<Vec<super::TrusteesDidsItem>>,
T::Error: ::std::fmt::Display,
{
self.dids = value
.try_into()
.map_err(|e| format!("error converting supplied value for dids: {e}"));
self
}
pub fn threshold<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<i64>,
T::Error: ::std::fmt::Display,
{
self.threshold = value
.try_into()
.map_err(|e| format!("error converting supplied value for threshold: {e}"));
self
}
}
impl ::std::convert::TryFrom<Trustees> for super::Trustees {
type Error = super::error::ConversionError;
fn try_from(value: Trustees) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
dids: value.dids?,
threshold: value.threshold?,
})
}
}
impl ::std::convert::From<super::Trustees> for Trustees {
fn from(value: super::Trustees) -> Self {
Self {
dids: Ok(value.dids),
threshold: Ok(value.threshold),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/voting/election/show/0.1";
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"BoardHead\": {\n \"additionalProperties\": false,\n \"description\": \"A board's tree head (RFC 9162 §2.1). A head is signed by being carried in a document the ballot box signs; whoever keeps a head keeps that whole document.\",\n \"properties\": {\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"issuedAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"rootHash\": {\n \"$ref\": \"#/$defs/DigestMultibase\",\n \"description\": \"The RFC 9162 Merkle tree hash (SHA-256) of the first `treeSize` entries, as a multihash.\"\n },\n \"treeSize\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"electionId\",\n \"treeSize\",\n \"rootHash\",\n \"issuedAt\"\n ],\n \"title\": \"BoardHead\",\n \"type\": \"object\"\n },\n \"BoardVisibility\": {\n \"description\": \"`public`: anyone reads the board. `private`: the community, the auditors the manifest names and, for one cast's inclusion, the holder of its receipt (VTI-VOT-052).\",\n \"enum\": [\n \"public\",\n \"private\"\n ],\n \"title\": \"BoardVisibility\",\n \"type\": \"string\"\n },\n \"DigestMultibase\": {\n \"description\": \"A cryptographic digest as a multibase-encoded multihash — the encoding the W3C Verifiable Credentials Data Model 2.0 defines for `digestMultibase`, and the one `did:webvh` uses for its SCID and entry hashes.\\n\\nMultihash carries the hash algorithm in-band, so the value is self-describing and the wire format survives an algorithm change without a schema revision; multibase does the same for the base encoding, so a verifier never infers base58 from base64url by context. A bare hex string or a `sha-256:`-style prefix hard-codes one algorithm into the wire contract and is non-conforming here.\\n\\nThis definition constrains the *encoding only*. What the digest is computed over is stated by each referencing field, because it differs legitimately: a digest over a JSON document is taken over its RFC 8785 (JCS) canonicalization, while a digest over an opaque artifact is taken over its bytes. A field whose input is a JSON document and which does not name a canonicalization is not reproducible.\\n\\nRestricted to the two multibase headers W3C Controlled Identifiers 1.0 §2.4 normatively requires — `z` (base58btc) and `u` (base64url-no-pad). CID permits others but states that \\\"interoperability is not guaranteed between implementations using such values\\\", and a registry whose purpose is interoperability should not mint digests a conforming verifier may be unable to read. The alphabets are enforced rather than assumed: base58btc excludes 0, O, I and l, and an earlier permissive pattern let three published examples carry digests that were not valid base58 at all. base58btc is RECOMMENDED, for consistency with `did:key` and `did:webvh`.\",\n \"examples\": [\n \"zQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR\"\n ],\n \"minLength\": 16,\n \"pattern\": \"^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$\",\n \"title\": \"DigestMultibase\",\n \"type\": \"string\"\n },\n \"ElectionId\": {\n \"description\": \"An election's identifier, unique within its community. A closed alphabet: it appears in the ticket class label `voter/<electionId>` and is framed into every hash a cast is bound to.\",\n \"pattern\": \"^[A-Za-z0-9._-]{1,128}$\",\n \"title\": \"ElectionId\",\n \"type\": \"string\"\n },\n \"ElectionState\": {\n \"enum\": [\n \"registered\",\n \"registration\",\n \"voting\",\n \"closed\",\n \"tallied\",\n \"cancelled\"\n ],\n \"title\": \"ElectionState\",\n \"type\": \"string\"\n },\n \"ElectionSummary\": {\n \"additionalProperties\": false,\n \"description\": \"A ballot box's view of one election.\",\n \"properties\": {\n \"ballotsAdmitted\": {\n \"description\": \"Distinct tags with a counted ballot.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"community\": {\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"head\": {\n \"$ref\": \"#/$defs/BoardHead\"\n },\n \"manifestDigest\": {\n \"$ref\": \"#/$defs/DigestMultibase\"\n },\n \"state\": {\n \"$ref\": \"#/$defs/ElectionState\"\n }\n },\n \"required\": [\n \"electionId\",\n \"community\",\n \"manifestDigest\",\n \"state\",\n \"ballotsAdmitted\",\n \"head\"\n ],\n \"title\": \"ElectionSummary\",\n \"type\": \"object\"\n },\n \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"Key\": {\n \"description\": \"A question or option key, unique within its manifest or question.\",\n \"pattern\": \"^[A-Za-z0-9._-]{1,64}$\",\n \"title\": \"Key\",\n \"type\": \"string\"\n },\n \"Manifest\": {\n \"additionalProperties\": false,\n \"description\": \"What an election asks and how it is decided (VTI-VOT-010). Its digest (`manifestDigest`) is the SHA-256 multihash of its RFC 8785 (JCS) canonicalization, and every cast is bound to it (VTI-VOT-011).\",\n \"properties\": {\n \"allowEarlyClose\": {\n \"type\": \"boolean\"\n },\n \"ballotBox\": {\n \"description\": \"The DID of the voting service that holds the board.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"binding\": {\n \"description\": \"Whether the community treats the result as deciding something; creating a binding election takes another administrator's consent (VTI-VOT-081).\",\n \"type\": \"boolean\"\n },\n \"board\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"auditors\": {\n \"items\": {\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"visibility\": {\n \"$ref\": \"#/$defs/BoardVisibility\"\n }\n },\n \"required\": [\n \"visibility\",\n \"auditors\"\n ],\n \"type\": \"object\"\n },\n \"community\": {\n \"description\": \"The community's DID.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"description\": {\n \"maxLength\": 8192,\n \"type\": \"string\"\n },\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"questions\": {\n \"items\": {\n \"$ref\": \"#/$defs/Question\"\n },\n \"maxItems\": 128,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"registrationOpens\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"resultsBeforeClose\": {\n \"description\": \"Open elections only: whether running totals may be read while voting is open (VTI-VOT-061).\",\n \"type\": \"boolean\"\n },\n \"revote\": {\n \"$ref\": \"#/$defs/Revote\"\n },\n \"roll\": {\n \"$ref\": \"#/$defs/RollRule\"\n },\n \"secrecy\": {\n \"$ref\": \"#/$defs/SecrecyLevel\"\n },\n \"textReleaseThreshold\": {\n \"description\": \"Counted ballots required before any text answer is disclosed (VTI-VOT-065).\",\n \"minimum\": 10,\n \"type\": \"integer\"\n },\n \"title\": {\n \"maxLength\": 512,\n \"type\": \"string\"\n },\n \"trustees\": {\n \"$ref\": \"#/$defs/Trustees\"\n },\n \"votingCloses\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"votingOpens\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"electionId\",\n \"community\",\n \"questions\",\n \"secrecy\",\n \"roll\",\n \"registrationOpens\",\n \"votingOpens\",\n \"votingCloses\",\n \"revote\",\n \"board\",\n \"ballotBox\",\n \"binding\",\n \"allowEarlyClose\",\n \"resultsBeforeClose\",\n \"textReleaseThreshold\"\n ],\n \"title\": \"Manifest\",\n \"type\": \"object\"\n },\n \"Question\": {\n \"description\": \"One question. Tagged union over `type`.\",\n \"oneOf\": [\n {\n \"additionalProperties\": false,\n \"description\": \"Select between `minSelections` and `maxSelections` of `options`. A yes/no/abstain motion is a choice of exactly one of three.\",\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"maxSelections\": {\n \"minimum\": 1,\n \"type\": \"integer\"\n },\n \"minSelections\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"optional\": {\n \"type\": \"boolean\"\n },\n \"options\": {\n \"items\": {\n \"$ref\": \"#/$defs/QuestionOption\"\n },\n \"maxItems\": 256,\n \"minItems\": 2,\n \"type\": \"array\"\n },\n \"text\": {\n \"maxLength\": 2048,\n \"type\": \"string\"\n },\n \"type\": {\n \"const\": \"choice\"\n }\n },\n \"required\": [\n \"key\",\n \"type\",\n \"options\",\n \"minSelections\",\n \"maxSelections\",\n \"optional\"\n ],\n \"title\": \"ChoiceQuestion\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"description\": \"Order `options`; a ballot ranks every option or, when `partial` is true, a prefix of them.\",\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"optional\": {\n \"type\": \"boolean\"\n },\n \"options\": {\n \"items\": {\n \"$ref\": \"#/$defs/QuestionOption\"\n },\n \"maxItems\": 64,\n \"minItems\": 2,\n \"type\": \"array\"\n },\n \"partial\": {\n \"type\": \"boolean\"\n },\n \"text\": {\n \"maxLength\": 2048,\n \"type\": \"string\"\n },\n \"type\": {\n \"const\": \"ranking\"\n }\n },\n \"required\": [\n \"key\",\n \"type\",\n \"options\",\n \"partial\",\n \"optional\"\n ],\n \"title\": \"RankingQuestion\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"description\": \"Give each option an integer score within [min, max].\",\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"max\": {\n \"type\": \"integer\"\n },\n \"min\": {\n \"type\": \"integer\"\n },\n \"optional\": {\n \"type\": \"boolean\"\n },\n \"options\": {\n \"items\": {\n \"$ref\": \"#/$defs/QuestionOption\"\n },\n \"maxItems\": 256,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"text\": {\n \"maxLength\": 2048,\n \"type\": \"string\"\n },\n \"type\": {\n \"const\": \"score\"\n }\n },\n \"required\": [\n \"key\",\n \"type\",\n \"options\",\n \"min\",\n \"max\",\n \"optional\"\n ],\n \"title\": \"ScoreQuestion\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"description\": \"Free text of at most `maxLength` characters.\",\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"maxLength\": {\n \"maximum\": 4096,\n \"minimum\": 1,\n \"type\": \"integer\"\n },\n \"optional\": {\n \"type\": \"boolean\"\n },\n \"text\": {\n \"maxLength\": 2048,\n \"type\": \"string\"\n },\n \"type\": {\n \"const\": \"text\"\n }\n },\n \"required\": [\n \"key\",\n \"type\",\n \"maxLength\",\n \"optional\"\n ],\n \"title\": \"TextQuestion\",\n \"type\": \"object\"\n }\n ],\n \"title\": \"Question\"\n },\n \"QuestionOption\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"label\": {\n \"description\": \"Display text. Absent from a manifest registered with a ballot box that holds no question text (VTI-VOT-014).\",\n \"maxLength\": 512,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"key\"\n ],\n \"title\": \"QuestionOption\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"properties\": {\n \"election\": {\n \"$ref\": \"#/$defs/ElectionSummary\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"manifest\": {\n \"$ref\": \"#/$defs/Manifest\",\n \"description\": \"The registered manifest, exactly as registered. Present when the board is public or the caller may read the private board.\"\n }\n },\n \"required\": [\n \"election\"\n ],\n \"title\": \"Voting — Election Show — response payload\",\n \"type\": \"object\"\n },\n \"Revote\": {\n \"description\": \"What a later, different ballot under one ticket does: `replace` the earlier one, or be refused (`refuse`) (VTI-VOT-041).\",\n \"enum\": [\n \"replace\",\n \"refuse\"\n ],\n \"title\": \"Revote\",\n \"type\": \"string\"\n },\n \"RollRule\": {\n \"additionalProperties\": false,\n \"description\": \"Who may be issued a ticket (VTI-VOT-021): the community's active members, its active members and the parties `listed` names, or only the parties `listed` names.\",\n \"properties\": {\n \"listed\": {\n \"items\": {\n \"description\": \"A DID enfranchised by name.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"rule\": {\n \"enum\": [\n \"members\",\n \"membersAndListed\",\n \"listed\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"rule\"\n ],\n \"title\": \"RollRule\",\n \"type\": \"object\"\n },\n \"SecrecyLevel\": {\n \"description\": \"`open`: ballots are recorded on the board as cast. `sealed`: ballots are encrypted to a jointly generated election key and decrypted after voting closes. `talliedEncrypted`: ballots are encrypted and only the totals are ever decrypted (VTI-VOT-060). The encrypted levels are cast with `voting/ballot/cast-encrypted/0.1`, under an election key the trustees generate with `voting/trustees/*` (CONVENTIONS §9).\",\n \"enum\": [\n \"open\",\n \"sealed\",\n \"talliedEncrypted\"\n ],\n \"title\": \"SecrecyLevel\",\n \"type\": \"string\"\n },\n \"Trustees\": {\n \"additionalProperties\": false,\n \"description\": \"The trustees of a sealed or tallied-encrypted election and the number of them decryption needs (VTI-VOT-062). Neither the community nor the ballot box may be one.\",\n \"properties\": {\n \"dids\": {\n \"items\": {\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"minItems\": 2,\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"threshold\": {\n \"minimum\": 2,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"dids\",\n \"threshold\"\n ],\n \"title\": \"Trustees\",\n \"type\": \"object\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/voting/election/show/0.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"Reads one election at its ballot box: its state, manifest digest, admitted count and current head, and the manifest where the caller may read the board.\",\n \"properties\": {\n \"community\": {\n \"description\": \"The community's DID.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n }\n },\n \"required\": [\n \"community\",\n \"electionId\"\n ],\n \"title\": \"Voting — Election Show — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/voting/election/show/0.1#response";
const IS_PROOF_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"BoardHead\": {\n \"additionalProperties\": false,\n \"description\": \"A board's tree head (RFC 9162 §2.1). A head is signed by being carried in a document the ballot box signs; whoever keeps a head keeps that whole document.\",\n \"properties\": {\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"issuedAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"rootHash\": {\n \"$ref\": \"#/$defs/DigestMultibase\",\n \"description\": \"The RFC 9162 Merkle tree hash (SHA-256) of the first `treeSize` entries, as a multihash.\"\n },\n \"treeSize\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"electionId\",\n \"treeSize\",\n \"rootHash\",\n \"issuedAt\"\n ],\n \"title\": \"BoardHead\",\n \"type\": \"object\"\n },\n \"BoardVisibility\": {\n \"description\": \"`public`: anyone reads the board. `private`: the community, the auditors the manifest names and, for one cast's inclusion, the holder of its receipt (VTI-VOT-052).\",\n \"enum\": [\n \"public\",\n \"private\"\n ],\n \"title\": \"BoardVisibility\",\n \"type\": \"string\"\n },\n \"DigestMultibase\": {\n \"description\": \"A cryptographic digest as a multibase-encoded multihash — the encoding the W3C Verifiable Credentials Data Model 2.0 defines for `digestMultibase`, and the one `did:webvh` uses for its SCID and entry hashes.\\n\\nMultihash carries the hash algorithm in-band, so the value is self-describing and the wire format survives an algorithm change without a schema revision; multibase does the same for the base encoding, so a verifier never infers base58 from base64url by context. A bare hex string or a `sha-256:`-style prefix hard-codes one algorithm into the wire contract and is non-conforming here.\\n\\nThis definition constrains the *encoding only*. What the digest is computed over is stated by each referencing field, because it differs legitimately: a digest over a JSON document is taken over its RFC 8785 (JCS) canonicalization, while a digest over an opaque artifact is taken over its bytes. A field whose input is a JSON document and which does not name a canonicalization is not reproducible.\\n\\nRestricted to the two multibase headers W3C Controlled Identifiers 1.0 §2.4 normatively requires — `z` (base58btc) and `u` (base64url-no-pad). CID permits others but states that \\\"interoperability is not guaranteed between implementations using such values\\\", and a registry whose purpose is interoperability should not mint digests a conforming verifier may be unable to read. The alphabets are enforced rather than assumed: base58btc excludes 0, O, I and l, and an earlier permissive pattern let three published examples carry digests that were not valid base58 at all. base58btc is RECOMMENDED, for consistency with `did:key` and `did:webvh`.\",\n \"examples\": [\n \"zQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR\"\n ],\n \"minLength\": 16,\n \"pattern\": \"^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$\",\n \"title\": \"DigestMultibase\",\n \"type\": \"string\"\n },\n \"ElectionId\": {\n \"description\": \"An election's identifier, unique within its community. A closed alphabet: it appears in the ticket class label `voter/<electionId>` and is framed into every hash a cast is bound to.\",\n \"pattern\": \"^[A-Za-z0-9._-]{1,128}$\",\n \"title\": \"ElectionId\",\n \"type\": \"string\"\n },\n \"ElectionState\": {\n \"enum\": [\n \"registered\",\n \"registration\",\n \"voting\",\n \"closed\",\n \"tallied\",\n \"cancelled\"\n ],\n \"title\": \"ElectionState\",\n \"type\": \"string\"\n },\n \"ElectionSummary\": {\n \"additionalProperties\": false,\n \"description\": \"A ballot box's view of one election.\",\n \"properties\": {\n \"ballotsAdmitted\": {\n \"description\": \"Distinct tags with a counted ballot.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"community\": {\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"head\": {\n \"$ref\": \"#/$defs/BoardHead\"\n },\n \"manifestDigest\": {\n \"$ref\": \"#/$defs/DigestMultibase\"\n },\n \"state\": {\n \"$ref\": \"#/$defs/ElectionState\"\n }\n },\n \"required\": [\n \"electionId\",\n \"community\",\n \"manifestDigest\",\n \"state\",\n \"ballotsAdmitted\",\n \"head\"\n ],\n \"title\": \"ElectionSummary\",\n \"type\": \"object\"\n },\n \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"Key\": {\n \"description\": \"A question or option key, unique within its manifest or question.\",\n \"pattern\": \"^[A-Za-z0-9._-]{1,64}$\",\n \"title\": \"Key\",\n \"type\": \"string\"\n },\n \"Manifest\": {\n \"additionalProperties\": false,\n \"description\": \"What an election asks and how it is decided (VTI-VOT-010). Its digest (`manifestDigest`) is the SHA-256 multihash of its RFC 8785 (JCS) canonicalization, and every cast is bound to it (VTI-VOT-011).\",\n \"properties\": {\n \"allowEarlyClose\": {\n \"type\": \"boolean\"\n },\n \"ballotBox\": {\n \"description\": \"The DID of the voting service that holds the board.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"binding\": {\n \"description\": \"Whether the community treats the result as deciding something; creating a binding election takes another administrator's consent (VTI-VOT-081).\",\n \"type\": \"boolean\"\n },\n \"board\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"auditors\": {\n \"items\": {\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"visibility\": {\n \"$ref\": \"#/$defs/BoardVisibility\"\n }\n },\n \"required\": [\n \"visibility\",\n \"auditors\"\n ],\n \"type\": \"object\"\n },\n \"community\": {\n \"description\": \"The community's DID.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"description\": {\n \"maxLength\": 8192,\n \"type\": \"string\"\n },\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"questions\": {\n \"items\": {\n \"$ref\": \"#/$defs/Question\"\n },\n \"maxItems\": 128,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"registrationOpens\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"resultsBeforeClose\": {\n \"description\": \"Open elections only: whether running totals may be read while voting is open (VTI-VOT-061).\",\n \"type\": \"boolean\"\n },\n \"revote\": {\n \"$ref\": \"#/$defs/Revote\"\n },\n \"roll\": {\n \"$ref\": \"#/$defs/RollRule\"\n },\n \"secrecy\": {\n \"$ref\": \"#/$defs/SecrecyLevel\"\n },\n \"textReleaseThreshold\": {\n \"description\": \"Counted ballots required before any text answer is disclosed (VTI-VOT-065).\",\n \"minimum\": 10,\n \"type\": \"integer\"\n },\n \"title\": {\n \"maxLength\": 512,\n \"type\": \"string\"\n },\n \"trustees\": {\n \"$ref\": \"#/$defs/Trustees\"\n },\n \"votingCloses\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"votingOpens\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"electionId\",\n \"community\",\n \"questions\",\n \"secrecy\",\n \"roll\",\n \"registrationOpens\",\n \"votingOpens\",\n \"votingCloses\",\n \"revote\",\n \"board\",\n \"ballotBox\",\n \"binding\",\n \"allowEarlyClose\",\n \"resultsBeforeClose\",\n \"textReleaseThreshold\"\n ],\n \"title\": \"Manifest\",\n \"type\": \"object\"\n },\n \"Question\": {\n \"description\": \"One question. Tagged union over `type`.\",\n \"oneOf\": [\n {\n \"additionalProperties\": false,\n \"description\": \"Select between `minSelections` and `maxSelections` of `options`. A yes/no/abstain motion is a choice of exactly one of three.\",\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"maxSelections\": {\n \"minimum\": 1,\n \"type\": \"integer\"\n },\n \"minSelections\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"optional\": {\n \"type\": \"boolean\"\n },\n \"options\": {\n \"items\": {\n \"$ref\": \"#/$defs/QuestionOption\"\n },\n \"maxItems\": 256,\n \"minItems\": 2,\n \"type\": \"array\"\n },\n \"text\": {\n \"maxLength\": 2048,\n \"type\": \"string\"\n },\n \"type\": {\n \"const\": \"choice\"\n }\n },\n \"required\": [\n \"key\",\n \"type\",\n \"options\",\n \"minSelections\",\n \"maxSelections\",\n \"optional\"\n ],\n \"title\": \"ChoiceQuestion\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"description\": \"Order `options`; a ballot ranks every option or, when `partial` is true, a prefix of them.\",\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"optional\": {\n \"type\": \"boolean\"\n },\n \"options\": {\n \"items\": {\n \"$ref\": \"#/$defs/QuestionOption\"\n },\n \"maxItems\": 64,\n \"minItems\": 2,\n \"type\": \"array\"\n },\n \"partial\": {\n \"type\": \"boolean\"\n },\n \"text\": {\n \"maxLength\": 2048,\n \"type\": \"string\"\n },\n \"type\": {\n \"const\": \"ranking\"\n }\n },\n \"required\": [\n \"key\",\n \"type\",\n \"options\",\n \"partial\",\n \"optional\"\n ],\n \"title\": \"RankingQuestion\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"description\": \"Give each option an integer score within [min, max].\",\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"max\": {\n \"type\": \"integer\"\n },\n \"min\": {\n \"type\": \"integer\"\n },\n \"optional\": {\n \"type\": \"boolean\"\n },\n \"options\": {\n \"items\": {\n \"$ref\": \"#/$defs/QuestionOption\"\n },\n \"maxItems\": 256,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"text\": {\n \"maxLength\": 2048,\n \"type\": \"string\"\n },\n \"type\": {\n \"const\": \"score\"\n }\n },\n \"required\": [\n \"key\",\n \"type\",\n \"options\",\n \"min\",\n \"max\",\n \"optional\"\n ],\n \"title\": \"ScoreQuestion\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"description\": \"Free text of at most `maxLength` characters.\",\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"maxLength\": {\n \"maximum\": 4096,\n \"minimum\": 1,\n \"type\": \"integer\"\n },\n \"optional\": {\n \"type\": \"boolean\"\n },\n \"text\": {\n \"maxLength\": 2048,\n \"type\": \"string\"\n },\n \"type\": {\n \"const\": \"text\"\n }\n },\n \"required\": [\n \"key\",\n \"type\",\n \"maxLength\",\n \"optional\"\n ],\n \"title\": \"TextQuestion\",\n \"type\": \"object\"\n }\n ],\n \"title\": \"Question\"\n },\n \"QuestionOption\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"label\": {\n \"description\": \"Display text. Absent from a manifest registered with a ballot box that holds no question text (VTI-VOT-014).\",\n \"maxLength\": 512,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"key\"\n ],\n \"title\": \"QuestionOption\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"properties\": {\n \"election\": {\n \"$ref\": \"#/$defs/ElectionSummary\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"manifest\": {\n \"$ref\": \"#/$defs/Manifest\",\n \"description\": \"The registered manifest, exactly as registered. Present when the board is public or the caller may read the private board.\"\n }\n },\n \"required\": [\n \"election\"\n ],\n \"title\": \"Voting — Election Show — response payload\",\n \"type\": \"object\"\n },\n \"Revote\": {\n \"description\": \"What a later, different ballot under one ticket does: `replace` the earlier one, or be refused (`refuse`) (VTI-VOT-041).\",\n \"enum\": [\n \"replace\",\n \"refuse\"\n ],\n \"title\": \"Revote\",\n \"type\": \"string\"\n },\n \"RollRule\": {\n \"additionalProperties\": false,\n \"description\": \"Who may be issued a ticket (VTI-VOT-021): the community's active members, its active members and the parties `listed` names, or only the parties `listed` names.\",\n \"properties\": {\n \"listed\": {\n \"items\": {\n \"description\": \"A DID enfranchised by name.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"rule\": {\n \"enum\": [\n \"members\",\n \"membersAndListed\",\n \"listed\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"rule\"\n ],\n \"title\": \"RollRule\",\n \"type\": \"object\"\n },\n \"SecrecyLevel\": {\n \"description\": \"`open`: ballots are recorded on the board as cast. `sealed`: ballots are encrypted to a jointly generated election key and decrypted after voting closes. `talliedEncrypted`: ballots are encrypted and only the totals are ever decrypted (VTI-VOT-060). The encrypted levels are cast with `voting/ballot/cast-encrypted/0.1`, under an election key the trustees generate with `voting/trustees/*` (CONVENTIONS §9).\",\n \"enum\": [\n \"open\",\n \"sealed\",\n \"talliedEncrypted\"\n ],\n \"title\": \"SecrecyLevel\",\n \"type\": \"string\"\n },\n \"Trustees\": {\n \"additionalProperties\": false,\n \"description\": \"The trustees of a sealed or tallied-encrypted election and the number of them decryption needs (VTI-VOT-062). Neither the community nor the ballot box may be one.\",\n \"properties\": {\n \"dids\": {\n \"items\": {\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"minItems\": 2,\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"threshold\": {\n \"minimum\": 2,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"dids\",\n \"threshold\"\n ],\n \"title\": \"Trustees\",\n \"type\": \"object\"\n }\n },\n \"$ref\": \"#/$defs/Response\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\n}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// The extended error codes this specification declares (SPEC §7.3 item 9,
/// §8.5), in declaration order. Empty when it declares none.
pub const ERROR_CODES: &[crate::DeclaredErrorCode] = &[error_codes::ELECTION_UNKNOWN];
/// One constant per extended error code this specification declares
/// (SPEC §7.3 item 9), named for its local part.
///
/// Emit these rather than a string literal: the code is read from the
/// specification, so it cannot name a code the specification never
/// declared.
pub mod error_codes {
/// `voting/election/show:electionUnknown`
///
/// No election with this identifier exists for this community, or the caller may not see it.
///
/// Declared `retryable: false`.
pub const ELECTION_UNKNOWN: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "voting/election/show:electionUnknown",
retryable: false,
details_schema: ::core::option::Option::None,
};
}