//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vtc/elections/show`. Version: `0.2`.
#[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()
}
}
///The community's certification of the election's result, as vtc/elections/certify recorded it.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Certification",
/// "description": "The community's certification of the election's result, as vtc/elections/certify recorded it.",
/// "type": "object",
/// "required": [
/// "auditAttestations",
/// "certifiedAt",
/// "result"
/// ],
/// "properties": {
/// "auditAttestations": {
/// "type": "array",
/// "items": {
/// "description": "A verifiable credential from an auditor the manifest names, as received.",
/// "type": "object"
/// },
/// "maxItems": 32
/// },
/// "certifiedAt": {
/// "type": "string",
/// "format": "date-time",
/// "maxLength": 64
/// },
/// "result": {
/// "$ref": "#/definitions/ElectionResult"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Certification {
#[serde(rename = "auditAttestations")]
pub audit_attestations:
::std::vec::Vec<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
#[serde(rename = "certifiedAt")]
pub certified_at: ::chrono::DateTime<::chrono::offset::Utc>,
pub result: ElectionResult,
}
impl Certification {
pub fn builder() -> builder::Certification {
Default::default()
}
}
///A board head the community read from the ballot box and kept, with the ballot box's signed document that carried it. Certification proves the board's final head consistent with every checkpoint, so a ballot box that rewrote its board after a checkpoint is caught.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Checkpoint",
/// "description": "A board head the community read from the ballot box and kept, with the ballot box's signed document that carried it. Certification proves the board's final head consistent with every checkpoint, so a ballot box that rewrote its board after a checkpoint is caught.",
/// "type": "object",
/// "required": [
/// "document",
/// "head"
/// ],
/// "properties": {
/// "document": {
/// "description": "The ballot box's signed voting/board/head `#response` document whose payload carries `head`, kept whole and exactly as received — proof included — so anyone can verify it against the ballot box's DID without trusting the community.",
/// "type": "object"
/// },
/// "head": {
/// "$ref": "#/definitions/BoardHead"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Checkpoint {
///The ballot box's signed voting/board/head `#response` document whose payload carries `head`, kept whole and exactly as received — proof included — so anyone can verify it against the ballot box's DID without trusting the community.
pub document: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
pub head: BoardHead,
}
impl Checkpoint {
pub fn builder() -> builder::Checkpoint {
Default::default()
}
}
/**
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())
})
}
}
///The statement a community publishes, and shows a member before they request a ticket, about how one election is run (VTI-VOT-090). Generated from the election's manifest and the community's configuration, never written by hand.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Disclosure",
/// "description": "The statement a community publishes, and shows a member before they request a ticket, about how one election is run (VTI-VOT-090). Generated from the election's manifest and the community's configuration, never written by hand.",
/// "type": "object",
/// "required": [
/// "auditors",
/// "ballotBox",
/// "ballotBoxOperator",
/// "boardVisibility",
/// "coercionResistance",
/// "revote",
/// "sameOperator"
/// ],
/// "properties": {
/// "auditors": {
/// "type": "array",
/// "items": {
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "uniqueItems": true
/// },
/// "ballotBox": {
/// "description": "The ballot box's DID.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "ballotBoxOperator": {
/// "description": "Who operates the ballot box, as the community names them.",
/// "type": "string",
/// "maxLength": 512,
/// "minLength": 1
/// },
/// "boardVisibility": {
/// "$ref": "#/definitions/BoardVisibility"
/// },
/// "coercionResistance": {
/// "description": "Always false: a voter can prove how they voted, so the community cannot protect a member against being made to vote a certain way.",
/// "const": false
/// },
/// "revote": {
/// "$ref": "#/definitions/Revote"
/// },
/// "sameOperator": {
/// "description": "Whether the party operating the community's VTC also operates the ballot box.",
/// "type": "boolean"
/// },
/// "trustees": {
/// "$ref": "#/definitions/Trustees"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Disclosure {
pub auditors: Vec<DisclosureAuditorsItem>,
///The ballot box's DID.
#[serde(rename = "ballotBox")]
pub ballot_box: DisclosureBallotBox,
///Who operates the ballot box, as the community names them.
#[serde(rename = "ballotBoxOperator")]
pub ballot_box_operator: DisclosureBallotBoxOperator,
#[serde(rename = "boardVisibility")]
pub board_visibility: BoardVisibility,
///Always false: a voter can prove how they voted, so the community cannot protect a member against being made to vote a certain way.
#[serde(rename = "coercionResistance")]
pub coercion_resistance: ::serde_json::Value,
pub revote: Revote,
///Whether the party operating the community's VTC also operates the ballot box.
#[serde(rename = "sameOperator")]
pub same_operator: bool,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub trustees: ::std::option::Option<Trustees>,
}
impl Disclosure {
pub fn builder() -> builder::Disclosure {
Default::default()
}
}
///`DisclosureAuditorsItem`
///
/// <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 DisclosureAuditorsItem(::std::string::String);
impl ::std::ops::Deref for DisclosureAuditorsItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<DisclosureAuditorsItem> for ::std::string::String {
fn from(value: DisclosureAuditorsItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for DisclosureAuditorsItem {
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 DisclosureAuditorsItem {
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 DisclosureAuditorsItem {
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 DisclosureAuditorsItem {
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 DisclosureAuditorsItem {
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 ballot box's DID.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The ballot box's DID.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct DisclosureBallotBox(::std::string::String);
impl ::std::ops::Deref for DisclosureBallotBox {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<DisclosureBallotBox> for ::std::string::String {
fn from(value: DisclosureBallotBox) -> Self {
value.0
}
}
impl ::std::str::FromStr for DisclosureBallotBox {
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 DisclosureBallotBox {
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 DisclosureBallotBox {
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 DisclosureBallotBox {
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 DisclosureBallotBox {
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())
})
}
}
///Who operates the ballot box, as the community names them.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Who operates the ballot box, as the community names them.",
/// "type": "string",
/// "maxLength": 512,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct DisclosureBallotBoxOperator(::std::string::String);
impl ::std::ops::Deref for DisclosureBallotBoxOperator {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<DisclosureBallotBoxOperator> for ::std::string::String {
fn from(value: DisclosureBallotBoxOperator) -> Self {
value.0
}
}
impl ::std::str::FromStr for DisclosureBallotBoxOperator {
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());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for DisclosureBallotBoxOperator {
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 DisclosureBallotBoxOperator {
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 DisclosureBallotBoxOperator {
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 DisclosureBallotBoxOperator {
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())
})
}
}
///The election key and each trustee's public verification key, computed from the qualified dealings (CONVENTIONS §9.6). Anyone can recompute it from the board.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ElectionKey",
/// "description": "The election key and each trustee's public verification key, computed from the qualified dealings (CONVENTIONS §9.6). Anyone can recompute it from the board.",
/// "type": "object",
/// "required": [
/// "key",
/// "qualified",
/// "verification"
/// ],
/// "properties": {
/// "key": {
/// "$ref": "#/definitions/GroupElement"
/// },
/// "qualified": {
/// "description": "The dealers whose dealings the key is formed from.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/TrusteeIndex"
/// },
/// "maxItems": 64,
/// "minItems": 1
/// },
/// "verification": {
/// "type": "array",
/// "items": {
/// "type": "object",
/// "required": [
/// "key",
/// "trustee"
/// ],
/// "properties": {
/// "key": {
/// "$ref": "#/definitions/GroupElement"
/// },
/// "trustee": {
/// "$ref": "#/definitions/TrusteeIndex"
/// }
/// },
/// "additionalProperties": false
/// },
/// "maxItems": 64,
/// "minItems": 2
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ElectionKey {
pub key: GroupElement,
///The dealers whose dealings the key is formed from.
pub qualified: ::std::vec::Vec<TrusteeIndex>,
pub verification: ::std::vec::Vec<ElectionKeyVerificationItem>,
}
impl ElectionKey {
pub fn builder() -> builder::ElectionKey {
Default::default()
}
}
///`ElectionKeyVerificationItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "key",
/// "trustee"
/// ],
/// "properties": {
/// "key": {
/// "$ref": "#/definitions/GroupElement"
/// },
/// "trustee": {
/// "$ref": "#/definitions/TrusteeIndex"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ElectionKeyVerificationItem {
pub key: GroupElement,
pub trustee: TrusteeIndex,
}
impl ElectionKeyVerificationItem {
pub fn builder() -> builder::ElectionKeyVerificationItem {
Default::default()
}
}
///An election's result, computable by anyone who can read its board from the board and the registration alone (VTI-VOT-070).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ElectionResult",
/// "description": "An election's result, computable by anyone who can read its board from the board and the registration alone (VTI-VOT-070).",
/// "type": "object",
/// "required": [
/// "ballotsCounted",
/// "electionId",
/// "head",
/// "manifestDigest",
/// "questions"
/// ],
/// "properties": {
/// "ballotsCounted": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "electionId": {
/// "$ref": "#/definitions/ElectionId"
/// },
/// "head": {
/// "description": "The head of the board as it stood at close: the result counts exactly its entries.",
/// "$ref": "#/definitions/BoardHead"
/// },
/// "manifestDigest": {
/// "$ref": "#/definitions/DigestMultibase"
/// },
/// "questions": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/QuestionResult"
/// }
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ElectionResult {
#[serde(rename = "ballotsCounted")]
pub ballots_counted: u64,
#[serde(rename = "electionId")]
pub election_id: ElectionId,
///The head of the board as it stood at close: the result counts exactly its entries.
pub head: BoardHead,
#[serde(rename = "manifestDigest")]
pub manifest_digest: DigestMultibase,
pub questions: ::std::vec::Vec<QuestionResult>,
}
impl ElectionResult {
pub fn builder() -> builder::ElectionResult {
Default::default()
}
}
///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 Ristretto group element: its 32-byte compression, multibase base58btc. Never the identity (CONVENTIONS §9.1).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "GroupElement",
/// "description": "A Ristretto group element: its 32-byte compression, multibase base58btc. Never the identity (CONVENTIONS §9.1).",
/// "type": "string",
/// "maxLength": 64,
/// "minLength": 2,
/// "pattern": "^z[1-9A-HJ-NP-Za-km-z]+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct GroupElement(::std::string::String);
impl ::std::ops::Deref for GroupElement {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<GroupElement> for ::std::string::String {
fn from(value: GroupElement) -> Self {
value.0
}
}
impl ::std::str::FromStr for GroupElement {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 64usize {
return Err("longer than 64 characters".into());
}
if value.chars().count() < 2usize {
return Err("shorter than 2 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^z[1-9A-HJ-NP-Za-km-z]+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^z[1-9A-HJ-NP-Za-km-z]+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for GroupElement {
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 GroupElement {
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 GroupElement {
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 GroupElement {
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",
/// "registrationOpensAt",
/// "resultsBeforeClose",
/// "revote",
/// "roll",
/// "secrecy",
/// "textReleaseThreshold",
/// "votingClosesAt",
/// "votingOpensAt"
/// ],
/// "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
/// },
/// "registrationOpensAt": {
/// "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"
/// },
/// "votingClosesAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "votingOpensAt": {
/// "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 = "registrationOpensAt")]
pub registration_opens_at: ::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 = "votingClosesAt")]
pub voting_closes_at: ::chrono::DateTime<::chrono::offset::Utc>,
#[serde(rename = "votingOpensAt")]
pub voting_opens_at: ::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())
})
}
}
///A binary value, multibase base58btc over the suite's canonical (compressed) encoding.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Multibase",
/// "description": "A binary value, multibase base58btc over the suite's canonical (compressed) encoding.",
/// "type": "string",
/// "maxLength": 16384,
/// "pattern": "^z[1-9A-HJ-NP-Za-km-z]+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct Multibase(::std::string::String);
impl ::std::ops::Deref for Multibase {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<Multibase> for ::std::string::String {
fn from(value: Multibase) -> Self {
value.0
}
}
impl ::std::str::FromStr for Multibase {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 16384usize {
return Err("longer than 16384 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^z[1-9A-HJ-NP-Za-km-z]+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^z[1-9A-HJ-NP-Za-km-z]+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for Multibase {
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 Multibase {
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 Multibase {
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 Multibase {
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 member or an administrator reads one election of the community whole: its manifest, state, voting parameters, disclosure, the board checkpoints the community kept and, once certified, the certified result. The outer document members (id, type, issuer, recipient, issuedAt, expiresAt, proof) are owned by the framework — SPEC §6.3.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/vtc/elections/show/0.2",
/// "title": "Payload",
/// "description": "A member or an administrator reads one election of the community whole: its manifest, state, voting parameters, disclosure, the board checkpoints the community kept and, once certified, the certified result. The outer document members (id, type, issuer, recipient, issuedAt, expiresAt, proof) are owned by the framework — SPEC §6.3.",
/// "type": "object",
/// "required": [
/// "electionId"
/// ],
/// "properties": {
/// "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 {
#[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()
}
}
///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())
})
}
}
///One question's totals. `choice`: selections per option. `ranking`: per option, how many ballots placed it at each position (index 0 = first). `score`: per option, the sum and the number of ballots that scored it. `text`: the answers, in board order, withheld (`withheld: true`) below the manifest's `textReleaseThreshold`. `abstained` counts ballots that left the question unanswered.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "QuestionResult",
/// "description": "One question's totals. `choice`: selections per option. `ranking`: per option, how many ballots placed it at each position (index 0 = first). `score`: per option, the sum and the number of ballots that scored it. `text`: the answers, in board order, withheld (`withheld: true`) below the manifest's `textReleaseThreshold`. `abstained` counts ballots that left the question unanswered.",
/// "type": "object",
/// "required": [
/// "abstained",
/// "question"
/// ],
/// "properties": {
/// "abstained": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "choice": {
/// "type": "object",
/// "additionalProperties": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "propertyNames": {
/// "$ref": "#/definitions/Key"
/// }
/// },
/// "question": {
/// "$ref": "#/definitions/Key"
/// },
/// "ranking": {
/// "type": "object",
/// "additionalProperties": {
/// "type": "array",
/// "items": {
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "propertyNames": {
/// "$ref": "#/definitions/Key"
/// }
/// },
/// "score": {
/// "type": "object",
/// "additionalProperties": {
/// "type": "object",
/// "required": [
/// "count",
/// "sum"
/// ],
/// "properties": {
/// "count": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "sum": {
/// "type": "integer"
/// }
/// },
/// "additionalProperties": false
/// },
/// "propertyNames": {
/// "$ref": "#/definitions/Key"
/// }
/// },
/// "text": {
/// "type": "array",
/// "items": {
/// "type": "string",
/// "maxLength": 4096
/// }
/// },
/// "withheld": {
/// "type": "boolean"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct QuestionResult {
pub abstained: u64,
#[serde(
default,
skip_serializing_if = ":: std :: collections :: HashMap::is_empty"
)]
pub choice: ::std::collections::HashMap<Key, u64>,
pub question: Key,
#[serde(
default,
skip_serializing_if = ":: std :: collections :: HashMap::is_empty"
)]
pub ranking: ::std::collections::HashMap<Key, ::std::vec::Vec<u64>>,
#[serde(
default,
skip_serializing_if = ":: std :: collections :: HashMap::is_empty"
)]
pub score: ::std::collections::HashMap<Key, QuestionResultScoreValue>,
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub text: ::std::vec::Vec<QuestionResultTextItem>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub withheld: ::std::option::Option<bool>,
}
impl QuestionResult {
pub fn builder() -> builder::QuestionResult {
Default::default()
}
}
///`QuestionResultScoreValue`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "count",
/// "sum"
/// ],
/// "properties": {
/// "count": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "sum": {
/// "type": "integer"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct QuestionResultScoreValue {
pub count: u64,
pub sum: i64,
}
impl QuestionResultScoreValue {
pub fn builder() -> builder::QuestionResultScoreValue {
Default::default()
}
}
///`QuestionResultTextItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 4096
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct QuestionResultTextItem(::std::string::String);
impl ::std::ops::Deref for QuestionResultTextItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<QuestionResultTextItem> for ::std::string::String {
fn from(value: QuestionResultTextItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for QuestionResultTextItem {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 4096usize {
return Err("longer than 4096 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for QuestionResultTextItem {
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 QuestionResultTextItem {
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 QuestionResultTextItem {
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 QuestionResultTextItem {
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())
})
}
}
///An election's state as its registrar holds it: the ballot box's `ElectionState` once the ballot box has registered the election, or, before that, `pendingRegistration` (the community is still delivering the registration) or `registrationRefused` (the ballot box refused it on a later delivery, and only a cancellation clears it). The first six values are the ballot box's `ElectionState` (voting/_shared/0.1).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "RegistrarState",
/// "description": "An election's state as its registrar holds it: the ballot box's `ElectionState` once the ballot box has registered the election, or, before that, `pendingRegistration` (the community is still delivering the registration) or `registrationRefused` (the ballot box refused it on a later delivery, and only a cancellation clears it). The first six values are the ballot box's `ElectionState` (voting/_shared/0.1).",
/// "type": "string",
/// "enum": [
/// "registered",
/// "registration",
/// "voting",
/// "closed",
/// "tallied",
/// "cancelled",
/// "pendingRegistration",
/// "registrationRefused"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum RegistrarState {
#[serde(rename = "registered")]
Registered,
#[serde(rename = "registration")]
Registration,
#[serde(rename = "voting")]
Voting,
#[serde(rename = "closed")]
Closed,
#[serde(rename = "tallied")]
Tallied,
#[serde(rename = "cancelled")]
Cancelled,
#[serde(rename = "pendingRegistration")]
PendingRegistration,
#[serde(rename = "registrationRefused")]
RegistrationRefused,
}
impl ::std::fmt::Display for RegistrarState {
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"),
Self::PendingRegistration => f.write_str("pendingRegistration"),
Self::RegistrationRefused => f.write_str("registrationRefused"),
}
}
}
impl ::std::str::FromStr for RegistrarState {
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),
"pendingRegistration" => Ok(Self::PendingRegistration),
"registrationRefused" => Ok(Self::RegistrationRefused),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for RegistrarState {
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 RegistrarState {
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 RegistrarState {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Success response to vtc/elections/show/0.1: one election, whole.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "Success response to vtc/elections/show/0.1: one election, whole.",
/// "type": "object",
/// "required": [
/// "checkpoints",
/// "disclosure",
/// "manifest",
/// "manifestDigest",
/// "parameters",
/// "state"
/// ],
/// "properties": {
/// "ceremony": {
/// "description": "With electionKey: the trustees' signed steps it forms from, through the board's electionKey entry, each exactly as received. A voter's VTA forms the key itself from these (vta/pcs/vote-encrypted/0.3).",
/// "$ref": "#/definitions/TrusteeCeremony"
/// },
/// "certified": {
/// "description": "Present once the community has certified the result.",
/// "$ref": "#/definitions/Certification"
/// },
/// "checkpoints": {
/// "description": "The board heads the community has kept, oldest first. Empty until the community has read a head.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/Checkpoint"
/// },
/// "maxItems": 256
/// },
/// "disclosure": {
/// "description": "How the election is run, generated from the manifest and the community's configuration (VTI-VOT-090). Always present: a member reads it before requesting a ticket.",
/// "$ref": "#/definitions/Disclosure"
/// },
/// "electionKey": {
/// "description": "The key a sealed or tallied-encrypted election's ballots are encrypted under, once its trustees have formed it (CONVENTIONS §9.6).",
/// "$ref": "#/definitions/ElectionKey"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "manifest": {
/// "$ref": "#/definitions/Manifest"
/// },
/// "manifestDigest": {
/// "description": "The SHA-256 multihash of the RFC 8785 (JCS) canonicalization of `manifest`. A ticket request names it, and every cast is bound to it.",
/// "$ref": "#/definitions/DigestMultibase"
/// },
/// "parameters": {
/// "description": "The community's voting parameters the election's tickets are issued under (VTI-VOT-020).",
/// "$ref": "#/definitions/VotingParameters"
/// },
/// "state": {
/// "$ref": "#/definitions/RegistrarState"
/// },
/// "ticketsIssued": {
/// "description": "How many tickets the community has issued for the election. Present only to a caller holding vtc.elections.manage.",
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
///With electionKey: the trustees' signed steps it forms from, through the board's electionKey entry, each exactly as received. A voter's VTA forms the key itself from these (vta/pcs/vote-encrypted/0.3).
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ceremony: ::std::option::Option<TrusteeCeremony>,
///Present once the community has certified the result.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub certified: ::std::option::Option<Certification>,
///The board heads the community has kept, oldest first. Empty until the community has read a head.
pub checkpoints: ::std::vec::Vec<Checkpoint>,
///How the election is run, generated from the manifest and the community's configuration (VTI-VOT-090). Always present: a member reads it before requesting a ticket.
pub disclosure: Disclosure,
///The key a sealed or tallied-encrypted election's ballots are encrypted under, once its trustees have formed it (CONVENTIONS §9.6).
#[serde(
rename = "electionKey",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub election_key: ::std::option::Option<ElectionKey>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
pub manifest: Manifest,
///The SHA-256 multihash of the RFC 8785 (JCS) canonicalization of `manifest`. A ticket request names it, and every cast is bound to it.
#[serde(rename = "manifestDigest")]
pub manifest_digest: DigestMultibase,
///The community's voting parameters the election's tickets are issued under (VTI-VOT-020).
pub parameters: VotingParameters,
pub state: RegistrarState,
///How many tickets the community has issued for the election. Present only to a caller holding vtc.elections.manage.
#[serde(
rename = "ticketsIssued",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub tickets_issued: ::std::option::Option<u64>,
}
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()
}
}
///A whole Trust Task request document — `id`, `type`, `issuer`, `payload` and every other member, `proof` included — exactly as the ballot box received it, never re-serialised: its proof is taken over its members, and a re-serialised copy does not reliably reproduce them. Typed as an open object so every member survives; CONVENTIONS §9.6 gives the checks that make it a trustee's step.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "SignedRequest",
/// "description": "A whole Trust Task request document — `id`, `type`, `issuer`, `payload` and every other member, `proof` included — exactly as the ballot box received it, never re-serialised: its proof is taken over its members, and a re-serialised copy does not reliably reproduce them. Typed as an open object so every member survives; CONVENTIONS §9.6 gives the checks that make it a trustee's step.",
/// "type": "object",
/// "minProperties": 1
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct SignedRequest(pub ::serde_json::Map<::std::string::String, ::serde_json::Value>);
impl ::std::ops::Deref for SignedRequest {
type Target = ::serde_json::Map<::std::string::String, ::serde_json::Value>;
fn deref(&self) -> &::serde_json::Map<::std::string::String, ::serde_json::Value> {
&self.0
}
}
impl ::std::convert::From<SignedRequest>
for ::serde_json::Map<::std::string::String, ::serde_json::Value>
{
fn from(value: SignedRequest) -> Self {
value.0
}
}
impl ::std::convert::From<::serde_json::Map<::std::string::String, ::serde_json::Value>>
for SignedRequest
{
fn from(value: ::serde_json::Map<::std::string::String, ::serde_json::Value>) -> Self {
Self(value)
}
}
///The trustees' ceremony as the board holds it: the `request` of every `trusteeStep` entry, in board order, each exactly as the ballot box received it (CONVENTIONS §9.6). Whoever acts on it verifies each step as its trustee's before taking it; nothing in it is believed for having been passed along.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "TrusteeCeremony",
/// "description": "The trustees' ceremony as the board holds it: the `request` of every `trusteeStep` entry, in board order, each exactly as the ballot box received it (CONVENTIONS §9.6). Whoever acts on it verifies each step as its trustee's before taking it; nothing in it is believed for having been passed along.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/SignedRequest"
/// },
/// "maxItems": 4224,
/// "minItems": 1
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct TrusteeCeremony(pub ::std::vec::Vec<SignedRequest>);
impl ::std::ops::Deref for TrusteeCeremony {
type Target = ::std::vec::Vec<SignedRequest>;
fn deref(&self) -> &::std::vec::Vec<SignedRequest> {
&self.0
}
}
impl ::std::convert::From<TrusteeCeremony> for ::std::vec::Vec<SignedRequest> {
fn from(value: TrusteeCeremony) -> Self {
value.0
}
}
impl ::std::convert::From<::std::vec::Vec<SignedRequest>> for TrusteeCeremony {
fn from(value: ::std::vec::Vec<SignedRequest>) -> Self {
Self(value)
}
}
///A trustee's index: its position in the manifest's `trustees.dids`, counting from 1.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "TrusteeIndex",
/// "description": "A trustee's index: its position in the manifest's `trustees.dids`, counting from 1.",
/// "type": "integer",
/// "maximum": 64.0,
/// "minimum": 1.0
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct TrusteeIndex(pub ::std::num::NonZeroU64);
impl ::std::ops::Deref for TrusteeIndex {
type Target = ::std::num::NonZeroU64;
fn deref(&self) -> &::std::num::NonZeroU64 {
&self.0
}
}
impl ::std::convert::From<TrusteeIndex> for ::std::num::NonZeroU64 {
fn from(value: TrusteeIndex) -> Self {
value.0
}
}
impl ::std::convert::From<::std::num::NonZeroU64> for TrusteeIndex {
fn from(value: ::std::num::NonZeroU64) -> Self {
Self(value)
}
}
impl ::std::str::FromStr for TrusteeIndex {
type Err = <::std::num::NonZeroU64 as ::std::str::FromStr>::Err;
fn from_str(value: &str) -> ::std::result::Result<Self, Self::Err> {
Ok(Self(value.parse()?))
}
}
impl ::std::convert::TryFrom<&str> for TrusteeIndex {
type Error = <::std::num::NonZeroU64 as ::std::str::FromStr>::Err;
fn try_from(value: &str) -> ::std::result::Result<Self, Self::Error> {
value.parse()
}
}
impl ::std::convert::TryFrom<String> for TrusteeIndex {
type Error = <::std::num::NonZeroU64 as ::std::str::FromStr>::Err;
fn try_from(value: String) -> ::std::result::Result<Self, Self::Error> {
value.parse()
}
}
impl ::std::fmt::Display for TrusteeIndex {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
self.0.fmt(f)
}
}
///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())
})
}
}
///The community's published voting parameters: the PCS suite and the voting verification key tickets are issued under (VTI-VOT-020). Distinct from its hidden-vetting helper key.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "VotingParameters",
/// "description": "The community's published voting parameters: the PCS suite and the voting verification key tickets are issued under (VTI-VOT-020). Distinct from its hidden-vetting helper key.",
/// "type": "object",
/// "required": [
/// "suite",
/// "votingKey"
/// ],
/// "properties": {
/// "suite": {
/// "type": "string",
/// "const": "ps-ddh-bls12381"
/// },
/// "votingKey": {
/// "$ref": "#/definitions/Multibase"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct VotingParameters {
pub suite: ::std::string::String,
#[serde(rename = "votingKey")]
pub voting_key: Multibase,
}
impl VotingParameters {
pub fn builder() -> builder::VotingParameters {
Default::default()
}
}
/// 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 Certification {
audit_attestations: ::std::result::Result<
::std::vec::Vec<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
::std::string::String,
>,
certified_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
result: ::std::result::Result<super::ElectionResult, ::std::string::String>,
}
impl ::std::default::Default for Certification {
fn default() -> Self {
Self {
audit_attestations: Err("no value supplied for audit_attestations".to_string()),
certified_at: Err("no value supplied for certified_at".to_string()),
result: Err("no value supplied for result".to_string()),
}
}
}
impl Certification {
pub fn audit_attestations<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::vec::Vec<::serde_json::Map<::std::string::String, ::serde_json::Value>>,
>,
T::Error: ::std::fmt::Display,
{
self.audit_attestations = value.try_into().map_err(|e| {
format!("error converting supplied value for audit_attestations: {e}")
});
self
}
pub fn certified_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.certified_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for certified_at: {e}"));
self
}
pub fn result<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElectionResult>,
T::Error: ::std::fmt::Display,
{
self.result = value
.try_into()
.map_err(|e| format!("error converting supplied value for result: {e}"));
self
}
}
impl ::std::convert::TryFrom<Certification> for super::Certification {
type Error = super::error::ConversionError;
fn try_from(
value: Certification,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
audit_attestations: value.audit_attestations?,
certified_at: value.certified_at?,
result: value.result?,
})
}
}
impl ::std::convert::From<super::Certification> for Certification {
fn from(value: super::Certification) -> Self {
Self {
audit_attestations: Ok(value.audit_attestations),
certified_at: Ok(value.certified_at),
result: Ok(value.result),
}
}
}
#[derive(Clone, Debug)]
pub struct Checkpoint {
document: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
head: ::std::result::Result<super::BoardHead, ::std::string::String>,
}
impl ::std::default::Default for Checkpoint {
fn default() -> Self {
Self {
document: Err("no value supplied for document".to_string()),
head: Err("no value supplied for head".to_string()),
}
}
}
impl Checkpoint {
pub fn document<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
>,
T::Error: ::std::fmt::Display,
{
self.document = value
.try_into()
.map_err(|e| format!("error converting supplied value for document: {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
}
}
impl ::std::convert::TryFrom<Checkpoint> for super::Checkpoint {
type Error = super::error::ConversionError;
fn try_from(
value: Checkpoint,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
document: value.document?,
head: value.head?,
})
}
}
impl ::std::convert::From<super::Checkpoint> for Checkpoint {
fn from(value: super::Checkpoint) -> Self {
Self {
document: Ok(value.document),
head: Ok(value.head),
}
}
}
#[derive(Clone, Debug)]
pub struct Disclosure {
auditors: ::std::result::Result<Vec<super::DisclosureAuditorsItem>, ::std::string::String>,
ballot_box: ::std::result::Result<super::DisclosureBallotBox, ::std::string::String>,
ballot_box_operator:
::std::result::Result<super::DisclosureBallotBoxOperator, ::std::string::String>,
board_visibility: ::std::result::Result<super::BoardVisibility, ::std::string::String>,
coercion_resistance: ::std::result::Result<::serde_json::Value, ::std::string::String>,
revote: ::std::result::Result<super::Revote, ::std::string::String>,
same_operator: ::std::result::Result<bool, ::std::string::String>,
trustees:
::std::result::Result<::std::option::Option<super::Trustees>, ::std::string::String>,
}
impl ::std::default::Default for Disclosure {
fn default() -> Self {
Self {
auditors: Err("no value supplied for auditors".to_string()),
ballot_box: Err("no value supplied for ballot_box".to_string()),
ballot_box_operator: Err("no value supplied for ballot_box_operator".to_string()),
board_visibility: Err("no value supplied for board_visibility".to_string()),
coercion_resistance: Err("no value supplied for coercion_resistance".to_string()),
revote: Err("no value supplied for revote".to_string()),
same_operator: Err("no value supplied for same_operator".to_string()),
trustees: Ok(Default::default()),
}
}
}
impl Disclosure {
pub fn auditors<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<Vec<super::DisclosureAuditorsItem>>,
T::Error: ::std::fmt::Display,
{
self.auditors = value
.try_into()
.map_err(|e| format!("error converting supplied value for auditors: {e}"));
self
}
pub fn ballot_box<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::DisclosureBallotBox>,
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 ballot_box_operator<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::DisclosureBallotBoxOperator>,
T::Error: ::std::fmt::Display,
{
self.ballot_box_operator = value.try_into().map_err(|e| {
format!("error converting supplied value for ballot_box_operator: {e}")
});
self
}
pub fn board_visibility<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::BoardVisibility>,
T::Error: ::std::fmt::Display,
{
self.board_visibility = value
.try_into()
.map_err(|e| format!("error converting supplied value for board_visibility: {e}"));
self
}
pub fn coercion_resistance<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::serde_json::Value>,
T::Error: ::std::fmt::Display,
{
self.coercion_resistance = value.try_into().map_err(|e| {
format!("error converting supplied value for coercion_resistance: {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 same_operator<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.same_operator = value
.try_into()
.map_err(|e| format!("error converting supplied value for same_operator: {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
}
}
impl ::std::convert::TryFrom<Disclosure> for super::Disclosure {
type Error = super::error::ConversionError;
fn try_from(
value: Disclosure,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
auditors: value.auditors?,
ballot_box: value.ballot_box?,
ballot_box_operator: value.ballot_box_operator?,
board_visibility: value.board_visibility?,
coercion_resistance: value.coercion_resistance?,
revote: value.revote?,
same_operator: value.same_operator?,
trustees: value.trustees?,
})
}
}
impl ::std::convert::From<super::Disclosure> for Disclosure {
fn from(value: super::Disclosure) -> Self {
Self {
auditors: Ok(value.auditors),
ballot_box: Ok(value.ballot_box),
ballot_box_operator: Ok(value.ballot_box_operator),
board_visibility: Ok(value.board_visibility),
coercion_resistance: Ok(value.coercion_resistance),
revote: Ok(value.revote),
same_operator: Ok(value.same_operator),
trustees: Ok(value.trustees),
}
}
}
#[derive(Clone, Debug)]
pub struct ElectionKey {
key: ::std::result::Result<super::GroupElement, ::std::string::String>,
qualified:
::std::result::Result<::std::vec::Vec<super::TrusteeIndex>, ::std::string::String>,
verification: ::std::result::Result<
::std::vec::Vec<super::ElectionKeyVerificationItem>,
::std::string::String,
>,
}
impl ::std::default::Default for ElectionKey {
fn default() -> Self {
Self {
key: Err("no value supplied for key".to_string()),
qualified: Err("no value supplied for qualified".to_string()),
verification: Err("no value supplied for verification".to_string()),
}
}
}
impl ElectionKey {
pub fn key<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::GroupElement>,
T::Error: ::std::fmt::Display,
{
self.key = value
.try_into()
.map_err(|e| format!("error converting supplied value for key: {e}"));
self
}
pub fn qualified<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::TrusteeIndex>>,
T::Error: ::std::fmt::Display,
{
self.qualified = value
.try_into()
.map_err(|e| format!("error converting supplied value for qualified: {e}"));
self
}
pub fn verification<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::ElectionKeyVerificationItem>>,
T::Error: ::std::fmt::Display,
{
self.verification = value
.try_into()
.map_err(|e| format!("error converting supplied value for verification: {e}"));
self
}
}
impl ::std::convert::TryFrom<ElectionKey> for super::ElectionKey {
type Error = super::error::ConversionError;
fn try_from(
value: ElectionKey,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
key: value.key?,
qualified: value.qualified?,
verification: value.verification?,
})
}
}
impl ::std::convert::From<super::ElectionKey> for ElectionKey {
fn from(value: super::ElectionKey) -> Self {
Self {
key: Ok(value.key),
qualified: Ok(value.qualified),
verification: Ok(value.verification),
}
}
}
#[derive(Clone, Debug)]
pub struct ElectionKeyVerificationItem {
key: ::std::result::Result<super::GroupElement, ::std::string::String>,
trustee: ::std::result::Result<super::TrusteeIndex, ::std::string::String>,
}
impl ::std::default::Default for ElectionKeyVerificationItem {
fn default() -> Self {
Self {
key: Err("no value supplied for key".to_string()),
trustee: Err("no value supplied for trustee".to_string()),
}
}
}
impl ElectionKeyVerificationItem {
pub fn key<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::GroupElement>,
T::Error: ::std::fmt::Display,
{
self.key = value
.try_into()
.map_err(|e| format!("error converting supplied value for key: {e}"));
self
}
pub fn trustee<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::TrusteeIndex>,
T::Error: ::std::fmt::Display,
{
self.trustee = value
.try_into()
.map_err(|e| format!("error converting supplied value for trustee: {e}"));
self
}
}
impl ::std::convert::TryFrom<ElectionKeyVerificationItem> for super::ElectionKeyVerificationItem {
type Error = super::error::ConversionError;
fn try_from(
value: ElectionKeyVerificationItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
key: value.key?,
trustee: value.trustee?,
})
}
}
impl ::std::convert::From<super::ElectionKeyVerificationItem> for ElectionKeyVerificationItem {
fn from(value: super::ElectionKeyVerificationItem) -> Self {
Self {
key: Ok(value.key),
trustee: Ok(value.trustee),
}
}
}
#[derive(Clone, Debug)]
pub struct ElectionResult {
ballots_counted: ::std::result::Result<u64, ::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>,
questions:
::std::result::Result<::std::vec::Vec<super::QuestionResult>, ::std::string::String>,
}
impl ::std::default::Default for ElectionResult {
fn default() -> Self {
Self {
ballots_counted: Err("no value supplied for ballots_counted".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()),
questions: Err("no value supplied for questions".to_string()),
}
}
}
impl ElectionResult {
pub fn ballots_counted<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.ballots_counted = value
.try_into()
.map_err(|e| format!("error converting supplied value for ballots_counted: {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 questions<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::QuestionResult>>,
T::Error: ::std::fmt::Display,
{
self.questions = value
.try_into()
.map_err(|e| format!("error converting supplied value for questions: {e}"));
self
}
}
impl ::std::convert::TryFrom<ElectionResult> for super::ElectionResult {
type Error = super::error::ConversionError;
fn try_from(
value: ElectionResult,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
ballots_counted: value.ballots_counted?,
election_id: value.election_id?,
head: value.head?,
manifest_digest: value.manifest_digest?,
questions: value.questions?,
})
}
}
impl ::std::convert::From<super::ElectionResult> for ElectionResult {
fn from(value: super::ElectionResult) -> Self {
Self {
ballots_counted: Ok(value.ballots_counted),
election_id: Ok(value.election_id),
head: Ok(value.head),
manifest_digest: Ok(value.manifest_digest),
questions: Ok(value.questions),
}
}
}
#[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_at:
::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_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
voting_opens_at:
::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_at: Err(
"no value supplied for registration_opens_at".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_at: Err("no value supplied for voting_closes_at".to_string()),
voting_opens_at: Err("no value supplied for voting_opens_at".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_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.registration_opens_at = value.try_into().map_err(|e| {
format!("error converting supplied value for registration_opens_at: {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_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.voting_closes_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for voting_closes_at: {e}"));
self
}
pub fn voting_opens_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.voting_opens_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for voting_opens_at: {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_at: value.registration_opens_at?,
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_at: value.voting_closes_at?,
voting_opens_at: value.voting_opens_at?,
})
}
}
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_at: Ok(value.registration_opens_at),
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_at: Ok(value.voting_closes_at),
voting_opens_at: Ok(value.voting_opens_at),
}
}
}
#[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 {
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 {
election_id: Err("no value supplied for election_id".to_string()),
ext: Ok(Default::default()),
}
}
}
impl Payload {
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 {
election_id: value.election_id?,
ext: value.ext?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
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 QuestionResult {
abstained: ::std::result::Result<u64, ::std::string::String>,
choice: ::std::result::Result<
::std::collections::HashMap<super::Key, u64>,
::std::string::String,
>,
question: ::std::result::Result<super::Key, ::std::string::String>,
ranking: ::std::result::Result<
::std::collections::HashMap<super::Key, ::std::vec::Vec<u64>>,
::std::string::String,
>,
score: ::std::result::Result<
::std::collections::HashMap<super::Key, super::QuestionResultScoreValue>,
::std::string::String,
>,
text: ::std::result::Result<
::std::vec::Vec<super::QuestionResultTextItem>,
::std::string::String,
>,
withheld: ::std::result::Result<::std::option::Option<bool>, ::std::string::String>,
}
impl ::std::default::Default for QuestionResult {
fn default() -> Self {
Self {
abstained: Err("no value supplied for abstained".to_string()),
choice: Ok(Default::default()),
question: Err("no value supplied for question".to_string()),
ranking: Ok(Default::default()),
score: Ok(Default::default()),
text: Ok(Default::default()),
withheld: Ok(Default::default()),
}
}
}
impl QuestionResult {
pub fn abstained<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.abstained = value
.try_into()
.map_err(|e| format!("error converting supplied value for abstained: {e}"));
self
}
pub fn choice<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::collections::HashMap<super::Key, u64>>,
T::Error: ::std::fmt::Display,
{
self.choice = value
.try_into()
.map_err(|e| format!("error converting supplied value for choice: {e}"));
self
}
pub fn question<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Key>,
T::Error: ::std::fmt::Display,
{
self.question = value
.try_into()
.map_err(|e| format!("error converting supplied value for question: {e}"));
self
}
pub fn ranking<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::collections::HashMap<super::Key, ::std::vec::Vec<u64>>,
>,
T::Error: ::std::fmt::Display,
{
self.ranking = value
.try_into()
.map_err(|e| format!("error converting supplied value for ranking: {e}"));
self
}
pub fn score<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::collections::HashMap<super::Key, super::QuestionResultScoreValue>,
>,
T::Error: ::std::fmt::Display,
{
self.score = value
.try_into()
.map_err(|e| format!("error converting supplied value for score: {e}"));
self
}
pub fn text<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::QuestionResultTextItem>>,
T::Error: ::std::fmt::Display,
{
self.text = value
.try_into()
.map_err(|e| format!("error converting supplied value for text: {e}"));
self
}
pub fn withheld<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.withheld = value
.try_into()
.map_err(|e| format!("error converting supplied value for withheld: {e}"));
self
}
}
impl ::std::convert::TryFrom<QuestionResult> for super::QuestionResult {
type Error = super::error::ConversionError;
fn try_from(
value: QuestionResult,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
abstained: value.abstained?,
choice: value.choice?,
question: value.question?,
ranking: value.ranking?,
score: value.score?,
text: value.text?,
withheld: value.withheld?,
})
}
}
impl ::std::convert::From<super::QuestionResult> for QuestionResult {
fn from(value: super::QuestionResult) -> Self {
Self {
abstained: Ok(value.abstained),
choice: Ok(value.choice),
question: Ok(value.question),
ranking: Ok(value.ranking),
score: Ok(value.score),
text: Ok(value.text),
withheld: Ok(value.withheld),
}
}
}
#[derive(Clone, Debug)]
pub struct QuestionResultScoreValue {
count: ::std::result::Result<u64, ::std::string::String>,
sum: ::std::result::Result<i64, ::std::string::String>,
}
impl ::std::default::Default for QuestionResultScoreValue {
fn default() -> Self {
Self {
count: Err("no value supplied for count".to_string()),
sum: Err("no value supplied for sum".to_string()),
}
}
}
impl QuestionResultScoreValue {
pub fn count<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.count = value
.try_into()
.map_err(|e| format!("error converting supplied value for count: {e}"));
self
}
pub fn sum<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<i64>,
T::Error: ::std::fmt::Display,
{
self.sum = value
.try_into()
.map_err(|e| format!("error converting supplied value for sum: {e}"));
self
}
}
impl ::std::convert::TryFrom<QuestionResultScoreValue> for super::QuestionResultScoreValue {
type Error = super::error::ConversionError;
fn try_from(
value: QuestionResultScoreValue,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
count: value.count?,
sum: value.sum?,
})
}
}
impl ::std::convert::From<super::QuestionResultScoreValue> for QuestionResultScoreValue {
fn from(value: super::QuestionResultScoreValue) -> Self {
Self {
count: Ok(value.count),
sum: Ok(value.sum),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
ceremony: ::std::result::Result<
::std::option::Option<super::TrusteeCeremony>,
::std::string::String,
>,
certified: ::std::result::Result<
::std::option::Option<super::Certification>,
::std::string::String,
>,
checkpoints:
::std::result::Result<::std::vec::Vec<super::Checkpoint>, ::std::string::String>,
disclosure: ::std::result::Result<super::Disclosure, ::std::string::String>,
election_key:
::std::result::Result<::std::option::Option<super::ElectionKey>, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
manifest: ::std::result::Result<super::Manifest, ::std::string::String>,
manifest_digest: ::std::result::Result<super::DigestMultibase, ::std::string::String>,
parameters: ::std::result::Result<super::VotingParameters, ::std::string::String>,
state: ::std::result::Result<super::RegistrarState, ::std::string::String>,
tickets_issued: ::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
ceremony: Ok(Default::default()),
certified: Ok(Default::default()),
checkpoints: Err("no value supplied for checkpoints".to_string()),
disclosure: Err("no value supplied for disclosure".to_string()),
election_key: Ok(Default::default()),
ext: Ok(Default::default()),
manifest: Err("no value supplied for manifest".to_string()),
manifest_digest: Err("no value supplied for manifest_digest".to_string()),
parameters: Err("no value supplied for parameters".to_string()),
state: Err("no value supplied for state".to_string()),
tickets_issued: Ok(Default::default()),
}
}
}
impl Response {
pub fn ceremony<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::TrusteeCeremony>>,
T::Error: ::std::fmt::Display,
{
self.ceremony = value
.try_into()
.map_err(|e| format!("error converting supplied value for ceremony: {e}"));
self
}
pub fn certified<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Certification>>,
T::Error: ::std::fmt::Display,
{
self.certified = value
.try_into()
.map_err(|e| format!("error converting supplied value for certified: {e}"));
self
}
pub fn checkpoints<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::Checkpoint>>,
T::Error: ::std::fmt::Display,
{
self.checkpoints = value
.try_into()
.map_err(|e| format!("error converting supplied value for checkpoints: {e}"));
self
}
pub fn disclosure<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Disclosure>,
T::Error: ::std::fmt::Display,
{
self.disclosure = value
.try_into()
.map_err(|e| format!("error converting supplied value for disclosure: {e}"));
self
}
pub fn election_key<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ElectionKey>>,
T::Error: ::std::fmt::Display,
{
self.election_key = value
.try_into()
.map_err(|e| format!("error converting supplied value for election_key: {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<super::Manifest>,
T::Error: ::std::fmt::Display,
{
self.manifest = value
.try_into()
.map_err(|e| format!("error converting supplied value for manifest: {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 parameters<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::VotingParameters>,
T::Error: ::std::fmt::Display,
{
self.parameters = value
.try_into()
.map_err(|e| format!("error converting supplied value for parameters: {e}"));
self
}
pub fn state<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::RegistrarState>,
T::Error: ::std::fmt::Display,
{
self.state = value
.try_into()
.map_err(|e| format!("error converting supplied value for state: {e}"));
self
}
pub fn tickets_issued<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.tickets_issued = value
.try_into()
.map_err(|e| format!("error converting supplied value for tickets_issued: {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 {
ceremony: value.ceremony?,
certified: value.certified?,
checkpoints: value.checkpoints?,
disclosure: value.disclosure?,
election_key: value.election_key?,
ext: value.ext?,
manifest: value.manifest?,
manifest_digest: value.manifest_digest?,
parameters: value.parameters?,
state: value.state?,
tickets_issued: value.tickets_issued?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
ceremony: Ok(value.ceremony),
certified: Ok(value.certified),
checkpoints: Ok(value.checkpoints),
disclosure: Ok(value.disclosure),
election_key: Ok(value.election_key),
ext: Ok(value.ext),
manifest: Ok(value.manifest),
manifest_digest: Ok(value.manifest_digest),
parameters: Ok(value.parameters),
state: Ok(value.state),
tickets_issued: Ok(value.tickets_issued),
}
}
}
#[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),
}
}
}
#[derive(Clone, Debug)]
pub struct VotingParameters {
suite: ::std::result::Result<::std::string::String, ::std::string::String>,
voting_key: ::std::result::Result<super::Multibase, ::std::string::String>,
}
impl ::std::default::Default for VotingParameters {
fn default() -> Self {
Self {
suite: Err("no value supplied for suite".to_string()),
voting_key: Err("no value supplied for voting_key".to_string()),
}
}
}
impl VotingParameters {
pub fn suite<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.suite = value
.try_into()
.map_err(|e| format!("error converting supplied value for suite: {e}"));
self
}
pub fn voting_key<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Multibase>,
T::Error: ::std::fmt::Display,
{
self.voting_key = value
.try_into()
.map_err(|e| format!("error converting supplied value for voting_key: {e}"));
self
}
}
impl ::std::convert::TryFrom<VotingParameters> for super::VotingParameters {
type Error = super::error::ConversionError;
fn try_from(
value: VotingParameters,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
suite: value.suite?,
voting_key: value.voting_key?,
})
}
}
impl ::std::convert::From<super::VotingParameters> for VotingParameters {
fn from(value: super::VotingParameters) -> Self {
Self {
suite: Ok(value.suite),
voting_key: Ok(value.voting_key),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vtc/elections/show/0.2";
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 \"Certification\": {\n \"additionalProperties\": false,\n \"description\": \"The community's certification of the election's result, as vtc/elections/certify recorded it.\",\n \"properties\": {\n \"auditAttestations\": {\n \"items\": {\n \"description\": \"A verifiable credential from an auditor the manifest names, as received.\",\n \"type\": \"object\"\n },\n \"maxItems\": 32,\n \"type\": \"array\"\n },\n \"certifiedAt\": {\n \"format\": \"date-time\",\n \"maxLength\": 64,\n \"type\": \"string\"\n },\n \"result\": {\n \"$ref\": \"#/$defs/ElectionResult\"\n }\n },\n \"required\": [\n \"result\",\n \"certifiedAt\",\n \"auditAttestations\"\n ],\n \"title\": \"Certification\",\n \"type\": \"object\"\n },\n \"Checkpoint\": {\n \"additionalProperties\": false,\n \"description\": \"A board head the community read from the ballot box and kept, with the ballot box's signed document that carried it. Certification proves the board's final head consistent with every checkpoint, so a ballot box that rewrote its board after a checkpoint is caught.\",\n \"properties\": {\n \"document\": {\n \"description\": \"The ballot box's signed voting/board/head `#response` document whose payload carries `head`, kept whole and exactly as received — proof included — so anyone can verify it against the ballot box's DID without trusting the community.\",\n \"type\": \"object\"\n },\n \"head\": {\n \"$ref\": \"#/$defs/BoardHead\"\n }\n },\n \"required\": [\n \"head\",\n \"document\"\n ],\n \"title\": \"Checkpoint\",\n \"type\": \"object\"\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 \"Disclosure\": {\n \"additionalProperties\": false,\n \"description\": \"The statement a community publishes, and shows a member before they request a ticket, about how one election is run (VTI-VOT-090). Generated from the election's manifest and the community's configuration, never written by hand.\",\n \"properties\": {\n \"auditors\": {\n \"items\": {\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"ballotBox\": {\n \"description\": \"The ballot box's DID.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"ballotBoxOperator\": {\n \"description\": \"Who operates the ballot box, as the community names them.\",\n \"maxLength\": 512,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"boardVisibility\": {\n \"$ref\": \"#/$defs/BoardVisibility\"\n },\n \"coercionResistance\": {\n \"const\": false,\n \"description\": \"Always false: a voter can prove how they voted, so the community cannot protect a member against being made to vote a certain way.\"\n },\n \"revote\": {\n \"$ref\": \"#/$defs/Revote\"\n },\n \"sameOperator\": {\n \"description\": \"Whether the party operating the community's VTC also operates the ballot box.\",\n \"type\": \"boolean\"\n },\n \"trustees\": {\n \"$ref\": \"#/$defs/Trustees\"\n }\n },\n \"required\": [\n \"ballotBox\",\n \"ballotBoxOperator\",\n \"sameOperator\",\n \"boardVisibility\",\n \"auditors\",\n \"revote\",\n \"coercionResistance\"\n ],\n \"title\": \"Disclosure\",\n \"type\": \"object\"\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 \"ElectionKey\": {\n \"additionalProperties\": false,\n \"description\": \"The election key and each trustee's public verification key, computed from the qualified dealings (CONVENTIONS §9.6). Anyone can recompute it from the board.\",\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/GroupElement\"\n },\n \"qualified\": {\n \"description\": \"The dealers whose dealings the key is formed from.\",\n \"items\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"maxItems\": 64,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"verification\": {\n \"items\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/GroupElement\"\n },\n \"trustee\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n }\n },\n \"required\": [\n \"trustee\",\n \"key\"\n ],\n \"type\": \"object\"\n },\n \"maxItems\": 64,\n \"minItems\": 2,\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"key\",\n \"qualified\",\n \"verification\"\n ],\n \"title\": \"ElectionKey\",\n \"type\": \"object\"\n },\n \"ElectionResult\": {\n \"additionalProperties\": false,\n \"description\": \"An election's result, computable by anyone who can read its board from the board and the registration alone (VTI-VOT-070).\",\n \"properties\": {\n \"ballotsCounted\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"head\": {\n \"$ref\": \"#/$defs/BoardHead\",\n \"description\": \"The head of the board as it stood at close: the result counts exactly its entries.\"\n },\n \"manifestDigest\": {\n \"$ref\": \"#/$defs/DigestMultibase\"\n },\n \"questions\": {\n \"items\": {\n \"$ref\": \"#/$defs/QuestionResult\"\n },\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"electionId\",\n \"manifestDigest\",\n \"ballotsCounted\",\n \"questions\",\n \"head\"\n ],\n \"title\": \"ElectionResult\",\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 \"GroupElement\": {\n \"description\": \"A Ristretto group element: its 32-byte compression, multibase base58btc. Never the identity (CONVENTIONS §9.1).\",\n \"maxLength\": 64,\n \"minLength\": 2,\n \"pattern\": \"^z[1-9A-HJ-NP-Za-km-z]+$\",\n \"title\": \"GroupElement\",\n \"type\": \"string\"\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 \"registrationOpensAt\": {\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 \"votingClosesAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"votingOpensAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"electionId\",\n \"community\",\n \"questions\",\n \"secrecy\",\n \"roll\",\n \"registrationOpensAt\",\n \"votingOpensAt\",\n \"votingClosesAt\",\n \"revote\",\n \"board\",\n \"ballotBox\",\n \"binding\",\n \"allowEarlyClose\",\n \"resultsBeforeClose\",\n \"textReleaseThreshold\"\n ],\n \"title\": \"Manifest\",\n \"type\": \"object\"\n },\n \"Multibase\": {\n \"description\": \"A binary value, multibase base58btc over the suite's canonical (compressed) encoding.\",\n \"maxLength\": 16384,\n \"pattern\": \"^z[1-9A-HJ-NP-Za-km-z]+$\",\n \"title\": \"Multibase\",\n \"type\": \"string\"\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 \"QuestionResult\": {\n \"additionalProperties\": false,\n \"description\": \"One question's totals. `choice`: selections per option. `ranking`: per option, how many ballots placed it at each position (index 0 = first). `score`: per option, the sum and the number of ballots that scored it. `text`: the answers, in board order, withheld (`withheld: true`) below the manifest's `textReleaseThreshold`. `abstained` counts ballots that left the question unanswered.\",\n \"properties\": {\n \"abstained\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"choice\": {\n \"additionalProperties\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"propertyNames\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"object\"\n },\n \"question\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"ranking\": {\n \"additionalProperties\": {\n \"items\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"type\": \"array\"\n },\n \"propertyNames\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"object\"\n },\n \"score\": {\n \"additionalProperties\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"count\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"sum\": {\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"sum\",\n \"count\"\n ],\n \"type\": \"object\"\n },\n \"propertyNames\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"object\"\n },\n \"text\": {\n \"items\": {\n \"maxLength\": 4096,\n \"type\": \"string\"\n },\n \"type\": \"array\"\n },\n \"withheld\": {\n \"type\": \"boolean\"\n }\n },\n \"required\": [\n \"question\",\n \"abstained\"\n ],\n \"title\": \"QuestionResult\",\n \"type\": \"object\"\n },\n \"RegistrarState\": {\n \"description\": \"An election's state as its registrar holds it: the ballot box's `ElectionState` once the ballot box has registered the election, or, before that, `pendingRegistration` (the community is still delivering the registration) or `registrationRefused` (the ballot box refused it on a later delivery, and only a cancellation clears it). The first six values are the ballot box's `ElectionState` (voting/_shared/0.1).\",\n \"enum\": [\n \"registered\",\n \"registration\",\n \"voting\",\n \"closed\",\n \"tallied\",\n \"cancelled\",\n \"pendingRegistration\",\n \"registrationRefused\"\n ],\n \"title\": \"RegistrarState\",\n \"type\": \"string\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"Success response to vtc/elections/show/0.1: one election, whole.\",\n \"properties\": {\n \"ceremony\": {\n \"$ref\": \"#/$defs/TrusteeCeremony\",\n \"description\": \"With electionKey: the trustees' signed steps it forms from, through the board's electionKey entry, each exactly as received. A voter's VTA forms the key itself from these (vta/pcs/vote-encrypted/0.3).\"\n },\n \"certified\": {\n \"$ref\": \"#/$defs/Certification\",\n \"description\": \"Present once the community has certified the result.\"\n },\n \"checkpoints\": {\n \"description\": \"The board heads the community has kept, oldest first. Empty until the community has read a head.\",\n \"items\": {\n \"$ref\": \"#/$defs/Checkpoint\"\n },\n \"maxItems\": 256,\n \"type\": \"array\"\n },\n \"disclosure\": {\n \"$ref\": \"#/$defs/Disclosure\",\n \"description\": \"How the election is run, generated from the manifest and the community's configuration (VTI-VOT-090). Always present: a member reads it before requesting a ticket.\"\n },\n \"electionKey\": {\n \"$ref\": \"#/$defs/ElectionKey\",\n \"description\": \"The key a sealed or tallied-encrypted election's ballots are encrypted under, once its trustees have formed it (CONVENTIONS §9.6).\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"manifest\": {\n \"$ref\": \"#/$defs/Manifest\"\n },\n \"manifestDigest\": {\n \"$ref\": \"#/$defs/DigestMultibase\",\n \"description\": \"The SHA-256 multihash of the RFC 8785 (JCS) canonicalization of `manifest`. A ticket request names it, and every cast is bound to it.\"\n },\n \"parameters\": {\n \"$ref\": \"#/$defs/VotingParameters\",\n \"description\": \"The community's voting parameters the election's tickets are issued under (VTI-VOT-020).\"\n },\n \"state\": {\n \"$ref\": \"#/$defs/RegistrarState\"\n },\n \"ticketsIssued\": {\n \"description\": \"How many tickets the community has issued for the election. Present only to a caller holding vtc.elections.manage.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"manifest\",\n \"manifestDigest\",\n \"state\",\n \"parameters\",\n \"disclosure\",\n \"checkpoints\"\n ],\n \"title\": \"VTC Elections — 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 \"SignedRequest\": {\n \"description\": \"A whole Trust Task request document — `id`, `type`, `issuer`, `payload` and every other member, `proof` included — exactly as the ballot box received it, never re-serialised: its proof is taken over its members, and a re-serialised copy does not reliably reproduce them. Typed as an open object so every member survives; CONVENTIONS §9.6 gives the checks that make it a trustee's step.\",\n \"minProperties\": 1,\n \"title\": \"SignedRequest\",\n \"type\": \"object\"\n },\n \"TrusteeCeremony\": {\n \"description\": \"The trustees' ceremony as the board holds it: the `request` of every `trusteeStep` entry, in board order, each exactly as the ballot box received it (CONVENTIONS §9.6). Whoever acts on it verifies each step as its trustee's before taking it; nothing in it is believed for having been passed along.\",\n \"items\": {\n \"$ref\": \"#/$defs/SignedRequest\"\n },\n \"maxItems\": 4224,\n \"minItems\": 1,\n \"title\": \"TrusteeCeremony\",\n \"type\": \"array\"\n },\n \"TrusteeIndex\": {\n \"description\": \"A trustee's index: its position in the manifest's `trustees.dids`, counting from 1.\",\n \"maximum\": 64,\n \"minimum\": 1,\n \"title\": \"TrusteeIndex\",\n \"type\": \"integer\"\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 \"VotingParameters\": {\n \"additionalProperties\": false,\n \"description\": \"The community's published voting parameters: the PCS suite and the voting verification key tickets are issued under (VTI-VOT-020). Distinct from its hidden-vetting helper key.\",\n \"properties\": {\n \"suite\": {\n \"const\": \"ps-ddh-bls12381\",\n \"type\": \"string\"\n },\n \"votingKey\": {\n \"$ref\": \"#/$defs/Multibase\"\n }\n },\n \"required\": [\n \"suite\",\n \"votingKey\"\n ],\n \"title\": \"VotingParameters\",\n \"type\": \"object\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/vtc/elections/show/0.2\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"A member or an administrator reads one election of the community whole: its manifest, state, voting parameters, disclosure, the board checkpoints the community kept and, once certified, the certified result. The outer document members (id, type, issuer, recipient, issuedAt, expiresAt, proof) are owned by the framework — SPEC §6.3.\",\n \"properties\": {\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n }\n },\n \"required\": [\n \"electionId\"\n ],\n \"title\": \"VTC Elections — Show — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vtc/elections/show/0.2#response";
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 \"Certification\": {\n \"additionalProperties\": false,\n \"description\": \"The community's certification of the election's result, as vtc/elections/certify recorded it.\",\n \"properties\": {\n \"auditAttestations\": {\n \"items\": {\n \"description\": \"A verifiable credential from an auditor the manifest names, as received.\",\n \"type\": \"object\"\n },\n \"maxItems\": 32,\n \"type\": \"array\"\n },\n \"certifiedAt\": {\n \"format\": \"date-time\",\n \"maxLength\": 64,\n \"type\": \"string\"\n },\n \"result\": {\n \"$ref\": \"#/$defs/ElectionResult\"\n }\n },\n \"required\": [\n \"result\",\n \"certifiedAt\",\n \"auditAttestations\"\n ],\n \"title\": \"Certification\",\n \"type\": \"object\"\n },\n \"Checkpoint\": {\n \"additionalProperties\": false,\n \"description\": \"A board head the community read from the ballot box and kept, with the ballot box's signed document that carried it. Certification proves the board's final head consistent with every checkpoint, so a ballot box that rewrote its board after a checkpoint is caught.\",\n \"properties\": {\n \"document\": {\n \"description\": \"The ballot box's signed voting/board/head `#response` document whose payload carries `head`, kept whole and exactly as received — proof included — so anyone can verify it against the ballot box's DID without trusting the community.\",\n \"type\": \"object\"\n },\n \"head\": {\n \"$ref\": \"#/$defs/BoardHead\"\n }\n },\n \"required\": [\n \"head\",\n \"document\"\n ],\n \"title\": \"Checkpoint\",\n \"type\": \"object\"\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 \"Disclosure\": {\n \"additionalProperties\": false,\n \"description\": \"The statement a community publishes, and shows a member before they request a ticket, about how one election is run (VTI-VOT-090). Generated from the election's manifest and the community's configuration, never written by hand.\",\n \"properties\": {\n \"auditors\": {\n \"items\": {\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"ballotBox\": {\n \"description\": \"The ballot box's DID.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"ballotBoxOperator\": {\n \"description\": \"Who operates the ballot box, as the community names them.\",\n \"maxLength\": 512,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"boardVisibility\": {\n \"$ref\": \"#/$defs/BoardVisibility\"\n },\n \"coercionResistance\": {\n \"const\": false,\n \"description\": \"Always false: a voter can prove how they voted, so the community cannot protect a member against being made to vote a certain way.\"\n },\n \"revote\": {\n \"$ref\": \"#/$defs/Revote\"\n },\n \"sameOperator\": {\n \"description\": \"Whether the party operating the community's VTC also operates the ballot box.\",\n \"type\": \"boolean\"\n },\n \"trustees\": {\n \"$ref\": \"#/$defs/Trustees\"\n }\n },\n \"required\": [\n \"ballotBox\",\n \"ballotBoxOperator\",\n \"sameOperator\",\n \"boardVisibility\",\n \"auditors\",\n \"revote\",\n \"coercionResistance\"\n ],\n \"title\": \"Disclosure\",\n \"type\": \"object\"\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 \"ElectionKey\": {\n \"additionalProperties\": false,\n \"description\": \"The election key and each trustee's public verification key, computed from the qualified dealings (CONVENTIONS §9.6). Anyone can recompute it from the board.\",\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/GroupElement\"\n },\n \"qualified\": {\n \"description\": \"The dealers whose dealings the key is formed from.\",\n \"items\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"maxItems\": 64,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"verification\": {\n \"items\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"key\": {\n \"$ref\": \"#/$defs/GroupElement\"\n },\n \"trustee\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n }\n },\n \"required\": [\n \"trustee\",\n \"key\"\n ],\n \"type\": \"object\"\n },\n \"maxItems\": 64,\n \"minItems\": 2,\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"key\",\n \"qualified\",\n \"verification\"\n ],\n \"title\": \"ElectionKey\",\n \"type\": \"object\"\n },\n \"ElectionResult\": {\n \"additionalProperties\": false,\n \"description\": \"An election's result, computable by anyone who can read its board from the board and the registration alone (VTI-VOT-070).\",\n \"properties\": {\n \"ballotsCounted\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"head\": {\n \"$ref\": \"#/$defs/BoardHead\",\n \"description\": \"The head of the board as it stood at close: the result counts exactly its entries.\"\n },\n \"manifestDigest\": {\n \"$ref\": \"#/$defs/DigestMultibase\"\n },\n \"questions\": {\n \"items\": {\n \"$ref\": \"#/$defs/QuestionResult\"\n },\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"electionId\",\n \"manifestDigest\",\n \"ballotsCounted\",\n \"questions\",\n \"head\"\n ],\n \"title\": \"ElectionResult\",\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 \"GroupElement\": {\n \"description\": \"A Ristretto group element: its 32-byte compression, multibase base58btc. Never the identity (CONVENTIONS §9.1).\",\n \"maxLength\": 64,\n \"minLength\": 2,\n \"pattern\": \"^z[1-9A-HJ-NP-Za-km-z]+$\",\n \"title\": \"GroupElement\",\n \"type\": \"string\"\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 \"registrationOpensAt\": {\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 \"votingClosesAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"votingOpensAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"electionId\",\n \"community\",\n \"questions\",\n \"secrecy\",\n \"roll\",\n \"registrationOpensAt\",\n \"votingOpensAt\",\n \"votingClosesAt\",\n \"revote\",\n \"board\",\n \"ballotBox\",\n \"binding\",\n \"allowEarlyClose\",\n \"resultsBeforeClose\",\n \"textReleaseThreshold\"\n ],\n \"title\": \"Manifest\",\n \"type\": \"object\"\n },\n \"Multibase\": {\n \"description\": \"A binary value, multibase base58btc over the suite's canonical (compressed) encoding.\",\n \"maxLength\": 16384,\n \"pattern\": \"^z[1-9A-HJ-NP-Za-km-z]+$\",\n \"title\": \"Multibase\",\n \"type\": \"string\"\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 \"QuestionResult\": {\n \"additionalProperties\": false,\n \"description\": \"One question's totals. `choice`: selections per option. `ranking`: per option, how many ballots placed it at each position (index 0 = first). `score`: per option, the sum and the number of ballots that scored it. `text`: the answers, in board order, withheld (`withheld: true`) below the manifest's `textReleaseThreshold`. `abstained` counts ballots that left the question unanswered.\",\n \"properties\": {\n \"abstained\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"choice\": {\n \"additionalProperties\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"propertyNames\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"object\"\n },\n \"question\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"ranking\": {\n \"additionalProperties\": {\n \"items\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"type\": \"array\"\n },\n \"propertyNames\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"object\"\n },\n \"score\": {\n \"additionalProperties\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"count\": {\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"sum\": {\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"sum\",\n \"count\"\n ],\n \"type\": \"object\"\n },\n \"propertyNames\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"object\"\n },\n \"text\": {\n \"items\": {\n \"maxLength\": 4096,\n \"type\": \"string\"\n },\n \"type\": \"array\"\n },\n \"withheld\": {\n \"type\": \"boolean\"\n }\n },\n \"required\": [\n \"question\",\n \"abstained\"\n ],\n \"title\": \"QuestionResult\",\n \"type\": \"object\"\n },\n \"RegistrarState\": {\n \"description\": \"An election's state as its registrar holds it: the ballot box's `ElectionState` once the ballot box has registered the election, or, before that, `pendingRegistration` (the community is still delivering the registration) or `registrationRefused` (the ballot box refused it on a later delivery, and only a cancellation clears it). The first six values are the ballot box's `ElectionState` (voting/_shared/0.1).\",\n \"enum\": [\n \"registered\",\n \"registration\",\n \"voting\",\n \"closed\",\n \"tallied\",\n \"cancelled\",\n \"pendingRegistration\",\n \"registrationRefused\"\n ],\n \"title\": \"RegistrarState\",\n \"type\": \"string\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"Success response to vtc/elections/show/0.1: one election, whole.\",\n \"properties\": {\n \"ceremony\": {\n \"$ref\": \"#/$defs/TrusteeCeremony\",\n \"description\": \"With electionKey: the trustees' signed steps it forms from, through the board's electionKey entry, each exactly as received. A voter's VTA forms the key itself from these (vta/pcs/vote-encrypted/0.3).\"\n },\n \"certified\": {\n \"$ref\": \"#/$defs/Certification\",\n \"description\": \"Present once the community has certified the result.\"\n },\n \"checkpoints\": {\n \"description\": \"The board heads the community has kept, oldest first. Empty until the community has read a head.\",\n \"items\": {\n \"$ref\": \"#/$defs/Checkpoint\"\n },\n \"maxItems\": 256,\n \"type\": \"array\"\n },\n \"disclosure\": {\n \"$ref\": \"#/$defs/Disclosure\",\n \"description\": \"How the election is run, generated from the manifest and the community's configuration (VTI-VOT-090). Always present: a member reads it before requesting a ticket.\"\n },\n \"electionKey\": {\n \"$ref\": \"#/$defs/ElectionKey\",\n \"description\": \"The key a sealed or tallied-encrypted election's ballots are encrypted under, once its trustees have formed it (CONVENTIONS §9.6).\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"manifest\": {\n \"$ref\": \"#/$defs/Manifest\"\n },\n \"manifestDigest\": {\n \"$ref\": \"#/$defs/DigestMultibase\",\n \"description\": \"The SHA-256 multihash of the RFC 8785 (JCS) canonicalization of `manifest`. A ticket request names it, and every cast is bound to it.\"\n },\n \"parameters\": {\n \"$ref\": \"#/$defs/VotingParameters\",\n \"description\": \"The community's voting parameters the election's tickets are issued under (VTI-VOT-020).\"\n },\n \"state\": {\n \"$ref\": \"#/$defs/RegistrarState\"\n },\n \"ticketsIssued\": {\n \"description\": \"How many tickets the community has issued for the election. Present only to a caller holding vtc.elections.manage.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"manifest\",\n \"manifestDigest\",\n \"state\",\n \"parameters\",\n \"disclosure\",\n \"checkpoints\"\n ],\n \"title\": \"VTC Elections — 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 \"SignedRequest\": {\n \"description\": \"A whole Trust Task request document — `id`, `type`, `issuer`, `payload` and every other member, `proof` included — exactly as the ballot box received it, never re-serialised: its proof is taken over its members, and a re-serialised copy does not reliably reproduce them. Typed as an open object so every member survives; CONVENTIONS §9.6 gives the checks that make it a trustee's step.\",\n \"minProperties\": 1,\n \"title\": \"SignedRequest\",\n \"type\": \"object\"\n },\n \"TrusteeCeremony\": {\n \"description\": \"The trustees' ceremony as the board holds it: the `request` of every `trusteeStep` entry, in board order, each exactly as the ballot box received it (CONVENTIONS §9.6). Whoever acts on it verifies each step as its trustee's before taking it; nothing in it is believed for having been passed along.\",\n \"items\": {\n \"$ref\": \"#/$defs/SignedRequest\"\n },\n \"maxItems\": 4224,\n \"minItems\": 1,\n \"title\": \"TrusteeCeremony\",\n \"type\": \"array\"\n },\n \"TrusteeIndex\": {\n \"description\": \"A trustee's index: its position in the manifest's `trustees.dids`, counting from 1.\",\n \"maximum\": 64,\n \"minimum\": 1,\n \"title\": \"TrusteeIndex\",\n \"type\": \"integer\"\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 \"VotingParameters\": {\n \"additionalProperties\": false,\n \"description\": \"The community's published voting parameters: the PCS suite and the voting verification key tickets are issued under (VTI-VOT-020). Distinct from its hidden-vetting helper key.\",\n \"properties\": {\n \"suite\": {\n \"const\": \"ps-ddh-bls12381\",\n \"type\": \"string\"\n },\n \"votingKey\": {\n \"$ref\": \"#/$defs/Multibase\"\n }\n },\n \"required\": [\n \"suite\",\n \"votingKey\"\n ],\n \"title\": \"VotingParameters\",\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 {
/// `vtc/elections/show:electionUnknown`
///
/// No election with this identifier exists for this community, or the caller may not see it. The two are answered identically (CONVENTIONS §7).
///
/// Declared `retryable: false`.
pub const ELECTION_UNKNOWN: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vtc/elections/show:electionUnknown",
retryable: false,
details_schema: ::core::option::Option::None,
};
}