//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vta/pcs/vote-encrypted`. Version: `0.1`.
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
///The answer to one question. Exactly one member besides `question` is present, matching the question's type, or `abstain` for an optional question left unanswered.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Answer",
/// "description": "The answer to one question. Exactly one member besides `question` is present, matching the question's type, or `abstain` for an optional question left unanswered.",
/// "type": "object",
/// "maxProperties": 2,
/// "minProperties": 2,
/// "required": [
/// "question"
/// ],
/// "properties": {
/// "abstain": {
/// "const": true
/// },
/// "choice": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/Key"
/// },
/// "uniqueItems": true
/// },
/// "question": {
/// "$ref": "#/definitions/Key"
/// },
/// "ranking": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/Key"
/// },
/// "uniqueItems": true
/// },
/// "scores": {
/// "type": "object",
/// "additionalProperties": {
/// "type": "integer"
/// },
/// "propertyNames": {
/// "$ref": "#/definitions/Key"
/// }
/// },
/// "text": {
/// "type": "string",
/// "maxLength": 4096
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Answer {
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub abstain: ::std::option::Option<::serde_json::Value>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub choice: ::std::option::Option<Vec<Key>>,
pub question: Key,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ranking: ::std::option::Option<Vec<Key>>,
#[serde(
default,
skip_serializing_if = ":: std :: collections :: HashMap::is_empty"
)]
pub scores: ::std::collections::HashMap<Key, i64>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub text: ::std::option::Option<AnswerText>,
}
impl Answer {
pub fn builder() -> builder::Answer {
Default::default()
}
}
///`AnswerText`
///
/// <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 AnswerText(::std::string::String);
impl ::std::ops::Deref for AnswerText {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<AnswerText> for ::std::string::String {
fn from(value: AnswerText) -> Self {
value.0
}
}
impl ::std::str::FromStr for AnswerText {
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 AnswerText {
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 AnswerText {
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 AnswerText {
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 AnswerText {
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 open ballot: one answer per question of the manifest, in any order. The bytes a cast's proof binds are the RFC 8785 (JCS) canonicalization of this object as received.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Ballot",
/// "description": "An open ballot: one answer per question of the manifest, in any order. The bytes a cast's proof binds are the RFC 8785 (JCS) canonicalization of this object as received.",
/// "type": "object",
/// "required": [
/// "answers",
/// "electionId",
/// "manifestDigest"
/// ],
/// "properties": {
/// "answers": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/Answer"
/// },
/// "maxItems": 128,
/// "minItems": 1
/// },
/// "electionId": {
/// "$ref": "#/definitions/ElectionId"
/// },
/// "manifestDigest": {
/// "$ref": "#/definitions/DigestMultibase"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Ballot {
pub answers: ::std::vec::Vec<Answer>,
#[serde(rename = "electionId")]
pub election_id: ElectionId,
#[serde(rename = "manifestDigest")]
pub manifest_digest: DigestMultibase,
}
impl Ballot {
pub fn builder() -> builder::Ballot {
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 voting/ballot/cast-encrypted request, signed by a key made for this cast alone (VTI-VOT-003).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "CastDocument",
/// "description": "The voting/ballot/cast-encrypted request, signed by a key made for this cast alone (VTI-VOT-003).",
/// "type": "object",
/// "required": [
/// "id",
/// "issuedAt",
/// "issuer",
/// "payload",
/// "proof",
/// "recipient",
/// "type"
/// ],
/// "properties": {
/// "expiresAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "id": {
/// "type": "string",
/// "pattern": "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
/// },
/// "issuedAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "issuer": {
/// "description": "The signer.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "payload": {
/// "description": "That task's request payload.",
/// "type": "object"
/// },
/// "proof": {
/// "description": "A Data Integrity proof by an `authentication` key of `issuer`.",
/// "type": "object"
/// },
/// "recipient": {
/// "description": "The ballot box.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "type": {
/// "const": "https://trusttasks.org/spec/voting/ballot/cast-encrypted/0.1"
/// }
/// }
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[non_exhaustive]
pub struct CastDocument {
#[serde(
rename = "expiresAt",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub expires_at: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
pub id: CastDocumentId,
#[serde(rename = "issuedAt")]
pub issued_at: ::chrono::DateTime<::chrono::offset::Utc>,
///The signer.
pub issuer: CastDocumentIssuer,
///That task's request payload.
pub payload: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
///A Data Integrity proof by an `authentication` key of `issuer`.
pub proof: ::serde_json::Map<::std::string::String, ::serde_json::Value>,
///The ballot box.
pub recipient: CastDocumentRecipient,
#[serde(rename = "type")]
pub type_: ::serde_json::Value,
}
impl CastDocument {
pub fn builder() -> builder::CastDocument {
Default::default()
}
}
///`CastDocumentId`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "pattern": "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct CastDocumentId(::std::string::String);
impl ::std::ops::Deref for CastDocumentId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<CastDocumentId> for ::std::string::String {
fn from(value: CastDocumentId) -> Self {
value.0
}
}
impl ::std::str::FromStr for CastDocumentId {
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(
"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$",
)
.unwrap()
},
);
if PATTERN.find(value).is_none() {
return Err(
"doesn't match pattern \"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$\""
.into(),
);
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for CastDocumentId {
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 CastDocumentId {
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 CastDocumentId {
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 CastDocumentId {
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 signer.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The signer.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct CastDocumentIssuer(::std::string::String);
impl ::std::ops::Deref for CastDocumentIssuer {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<CastDocumentIssuer> for ::std::string::String {
fn from(value: CastDocumentIssuer) -> Self {
value.0
}
}
impl ::std::str::FromStr for CastDocumentIssuer {
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 CastDocumentIssuer {
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 CastDocumentIssuer {
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 CastDocumentIssuer {
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 CastDocumentIssuer {
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.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The ballot box.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct CastDocumentRecipient(::std::string::String);
impl ::std::ops::Deref for CastDocumentRecipient {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<CastDocumentRecipient> for ::std::string::String {
fn from(value: CastDocumentRecipient) -> Self {
value.0
}
}
impl ::std::str::FromStr for CastDocumentRecipient {
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 CastDocumentRecipient {
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 CastDocumentRecipient {
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 CastDocumentRecipient {
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 CastDocumentRecipient {
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 cryptographic digest as a multibase-encoded multihash — the encoding the W3C Verifiable Credentials Data Model 2.0 defines for `digestMultibase`, and the one `did:webvh` uses for its SCID and entry hashes.
Multihash carries the hash algorithm in-band, so the value is self-describing and the wire format survives an algorithm change without a schema revision; multibase does the same for the base encoding, so a verifier never infers base58 from base64url by context. A bare hex string or a `sha-256:`-style prefix hard-codes one algorithm into the wire contract and is non-conforming here.
This definition constrains the *encoding only*. What the digest is computed over is stated by each referencing field, because it differs legitimately: a digest over a JSON document is taken over its RFC 8785 (JCS) canonicalization, while a digest over an opaque artifact is taken over its bytes. A field whose input is a JSON document and which does not name a canonicalization is not reproducible.
Restricted to the two multibase headers W3C Controlled Identifiers 1.0 §2.4 normatively requires — `z` (base58btc) and `u` (base64url-no-pad). CID permits others but states that "interoperability is not guaranteed between implementations using such values", and a registry whose purpose is interoperability should not mint digests a conforming verifier may be unable to read. The alphabets are enforced rather than assumed: base58btc excludes 0, O, I and l, and an earlier permissive pattern let three published examples carry digests that were not valid base58 at all. base58btc is RECOMMENDED, for consistency with `did:key` and `did:webvh`.*/
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "DigestMultibase",
/// "description": "A cryptographic digest as a multibase-encoded multihash — the encoding the W3C Verifiable Credentials Data Model 2.0 defines for `digestMultibase`, and the one `did:webvh` uses for its SCID and entry hashes.\n\nMultihash carries the hash algorithm in-band, so the value is self-describing and the wire format survives an algorithm change without a schema revision; multibase does the same for the base encoding, so a verifier never infers base58 from base64url by context. A bare hex string or a `sha-256:`-style prefix hard-codes one algorithm into the wire contract and is non-conforming here.\n\nThis definition constrains the *encoding only*. What the digest is computed over is stated by each referencing field, because it differs legitimately: a digest over a JSON document is taken over its RFC 8785 (JCS) canonicalization, while a digest over an opaque artifact is taken over its bytes. A field whose input is a JSON document and which does not name a canonicalization is not reproducible.\n\nRestricted to the two multibase headers W3C Controlled Identifiers 1.0 §2.4 normatively requires — `z` (base58btc) and `u` (base64url-no-pad). CID permits others but states that \"interoperability is not guaranteed between implementations using such values\", and a registry whose purpose is interoperability should not mint digests a conforming verifier may be unable to read. The alphabets are enforced rather than assumed: base58btc excludes 0, O, I and l, and an earlier permissive pattern let three published examples carry digests that were not valid base58 at all. base58btc is RECOMMENDED, for consistency with `did:key` and `did:webvh`.",
/// "examples": [
/// "zQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR"
/// ],
/// "type": "string",
/// "minLength": 16,
/// "pattern": "^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct DigestMultibase(::std::string::String);
impl ::std::ops::Deref for DigestMultibase {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<DigestMultibase> for ::std::string::String {
fn from(value: DigestMultibase) -> Self {
value.0
}
}
impl ::std::str::FromStr for DigestMultibase {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 16usize {
return Err("shorter than 16 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err(
"doesn't match pattern \"^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$\"".into(),
);
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for DigestMultibase {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for DigestMultibase {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for DigestMultibase {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for DigestMultibase {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///An election's identifier, unique within its community. A closed alphabet: it appears in the ticket class label `voter/<electionId>` and is framed into every hash a cast is bound to.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ElectionId",
/// "description": "An election's identifier, unique within its community. A closed alphabet: it appears in the ticket class label `voter/<electionId>` and is framed into every hash a cast is bound to.",
/// "type": "string",
/// "pattern": "^[A-Za-z0-9._-]{1,128}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ElectionId(::std::string::String);
impl ::std::ops::Deref for ElectionId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ElectionId> for ::std::string::String {
fn from(value: ElectionId) -> Self {
value.0
}
}
impl ::std::str::FromStr for ElectionId {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^[A-Za-z0-9._-]{1,128}$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[A-Za-z0-9._-]{1,128}$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ElectionId {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ElectionId {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ElectionId {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ElectionId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///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()
}
}
///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",
/// "registrationOpens",
/// "resultsBeforeClose",
/// "revote",
/// "roll",
/// "secrecy",
/// "textReleaseThreshold",
/// "votingCloses",
/// "votingOpens"
/// ],
/// "properties": {
/// "allowEarlyClose": {
/// "type": "boolean"
/// },
/// "ballotBox": {
/// "description": "The DID of the voting service that holds the board.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "binding": {
/// "description": "Whether the community treats the result as deciding something; creating a binding election takes another administrator's consent (VTI-VOT-081).",
/// "type": "boolean"
/// },
/// "board": {
/// "type": "object",
/// "required": [
/// "auditors",
/// "visibility"
/// ],
/// "properties": {
/// "auditors": {
/// "type": "array",
/// "items": {
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "uniqueItems": true
/// },
/// "visibility": {
/// "$ref": "#/definitions/BoardVisibility"
/// }
/// },
/// "additionalProperties": false
/// },
/// "community": {
/// "description": "The community's DID.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "description": {
/// "type": "string",
/// "maxLength": 8192
/// },
/// "electionId": {
/// "$ref": "#/definitions/ElectionId"
/// },
/// "questions": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/Question"
/// },
/// "maxItems": 128,
/// "minItems": 1
/// },
/// "registrationOpens": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "resultsBeforeClose": {
/// "description": "Open elections only: whether running totals may be read while voting is open (VTI-VOT-061).",
/// "type": "boolean"
/// },
/// "revote": {
/// "$ref": "#/definitions/Revote"
/// },
/// "roll": {
/// "$ref": "#/definitions/RollRule"
/// },
/// "secrecy": {
/// "$ref": "#/definitions/SecrecyLevel"
/// },
/// "textReleaseThreshold": {
/// "description": "Counted ballots required before any text answer is disclosed (VTI-VOT-065).",
/// "type": "integer",
/// "minimum": 10.0
/// },
/// "title": {
/// "type": "string",
/// "maxLength": 512
/// },
/// "trustees": {
/// "$ref": "#/definitions/Trustees"
/// },
/// "votingCloses": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "votingOpens": {
/// "type": "string",
/// "format": "date-time"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Manifest {
#[serde(rename = "allowEarlyClose")]
pub allow_early_close: bool,
///The DID of the voting service that holds the board.
#[serde(rename = "ballotBox")]
pub ballot_box: ManifestBallotBox,
///Whether the community treats the result as deciding something; creating a binding election takes another administrator's consent (VTI-VOT-081).
pub binding: bool,
pub board: ManifestBoard,
///The community's DID.
pub community: ManifestCommunity,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub description: ::std::option::Option<ManifestDescription>,
#[serde(rename = "electionId")]
pub election_id: ElectionId,
pub questions: ::std::vec::Vec<Question>,
#[serde(rename = "registrationOpens")]
pub registration_opens: ::chrono::DateTime<::chrono::offset::Utc>,
///Open elections only: whether running totals may be read while voting is open (VTI-VOT-061).
#[serde(rename = "resultsBeforeClose")]
pub results_before_close: bool,
pub revote: Revote,
pub roll: RollRule,
pub secrecy: SecrecyLevel,
///Counted ballots required before any text answer is disclosed (VTI-VOT-065).
#[serde(rename = "textReleaseThreshold")]
pub text_release_threshold: i64,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub title: ::std::option::Option<ManifestTitle>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub trustees: ::std::option::Option<Trustees>,
#[serde(rename = "votingCloses")]
pub voting_closes: ::chrono::DateTime<::chrono::offset::Utc>,
#[serde(rename = "votingOpens")]
pub voting_opens: ::chrono::DateTime<::chrono::offset::Utc>,
}
impl Manifest {
pub fn builder() -> builder::Manifest {
Default::default()
}
}
///The DID of the voting service that holds the board.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The DID of the voting service that holds the board.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ManifestBallotBox(::std::string::String);
impl ::std::ops::Deref for ManifestBallotBox {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ManifestBallotBox> for ::std::string::String {
fn from(value: ManifestBallotBox) -> Self {
value.0
}
}
impl ::std::str::FromStr for ManifestBallotBox {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ManifestBallotBox {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ManifestBallotBox {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ManifestBallotBox {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ManifestBallotBox {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`ManifestBoard`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "auditors",
/// "visibility"
/// ],
/// "properties": {
/// "auditors": {
/// "type": "array",
/// "items": {
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "uniqueItems": true
/// },
/// "visibility": {
/// "$ref": "#/definitions/BoardVisibility"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ManifestBoard {
pub auditors: Vec<ManifestBoardAuditorsItem>,
pub visibility: BoardVisibility,
}
impl ManifestBoard {
pub fn builder() -> builder::ManifestBoard {
Default::default()
}
}
///`ManifestBoardAuditorsItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ManifestBoardAuditorsItem(::std::string::String);
impl ::std::ops::Deref for ManifestBoardAuditorsItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ManifestBoardAuditorsItem> for ::std::string::String {
fn from(value: ManifestBoardAuditorsItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for ManifestBoardAuditorsItem {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ManifestBoardAuditorsItem {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ManifestBoardAuditorsItem {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ManifestBoardAuditorsItem {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ManifestBoardAuditorsItem {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///The community's DID.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The community's DID.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ManifestCommunity(::std::string::String);
impl ::std::ops::Deref for ManifestCommunity {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ManifestCommunity> for ::std::string::String {
fn from(value: ManifestCommunity) -> Self {
value.0
}
}
impl ::std::str::FromStr for ManifestCommunity {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ManifestCommunity {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ManifestCommunity {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ManifestCommunity {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ManifestCommunity {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`ManifestDescription`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 8192
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ManifestDescription(::std::string::String);
impl ::std::ops::Deref for ManifestDescription {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ManifestDescription> for ::std::string::String {
fn from(value: ManifestDescription) -> Self {
value.0
}
}
impl ::std::str::FromStr for ManifestDescription {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 8192usize {
return Err("longer than 8192 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ManifestDescription {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ManifestDescription {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ManifestDescription {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ManifestDescription {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`ManifestTitle`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 512
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ManifestTitle(::std::string::String);
impl ::std::ops::Deref for ManifestTitle {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ManifestTitle> for ::std::string::String {
fn from(value: ManifestTitle) -> Self {
value.0
}
}
impl ::std::str::FromStr for ManifestTitle {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 512usize {
return Err("longer than 512 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ManifestTitle {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ManifestTitle {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ManifestTitle {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ManifestTitle {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///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())
})
}
}
///The voter's VTA checks a ballot against the manifest, encrypts it to the election key as the election's level requires, and returns the cast signed by a key made for it alone.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/vta/pcs/vote-encrypted/0.1",
/// "title": "Payload",
/// "description": "The voter's VTA checks a ballot against the manifest, encrypts it to the election key as the election's level requires, and returns the cast signed by a key made for it alone.",
/// "type": "object",
/// "required": [
/// "ballot",
/// "community",
/// "contextId",
/// "electionKey",
/// "manifest",
/// "parameters"
/// ],
/// "properties": {
/// "ballot": {
/// "$ref": "#/definitions/Ballot"
/// },
/// "community": {
/// "description": "The community's DID.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "contextId": {
/// "description": "The context the voter belongs to.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
/// },
/// "electionKey": {
/// "$ref": "#/definitions/ElectionKey"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "manifest": {
/// "$ref": "#/definitions/Manifest"
/// },
/// "parameters": {
/// "$ref": "#/definitions/VotingParameters"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
pub ballot: Ballot,
///The community's DID.
pub community: PayloadCommunity,
///The context the voter belongs to.
#[serde(rename = "contextId")]
pub context_id: PayloadContextId,
#[serde(rename = "electionKey")]
pub election_key: ElectionKey,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
pub manifest: Manifest,
pub parameters: VotingParameters,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///The community's DID.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The community's DID.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadCommunity(::std::string::String);
impl ::std::ops::Deref for PayloadCommunity {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadCommunity> for ::std::string::String {
fn from(value: PayloadCommunity) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadCommunity {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadCommunity {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for PayloadCommunity {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for PayloadCommunity {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for PayloadCommunity {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///The context the voter belongs to.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The context the voter belongs to.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadContextId(::std::string::String);
impl ::std::ops::Deref for PayloadContextId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadContextId> for ::std::string::String {
fn from(value: PayloadContextId) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadContextId {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 256usize {
return Err("longer than 256 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 PayloadContextId {
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 PayloadContextId {
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 PayloadContextId {
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 PayloadContextId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///One question. Tagged union over `type`.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Question",
/// "description": "One question. Tagged union over `type`.",
/// "oneOf": [
/// {
/// "title": "ChoiceQuestion",
/// "description": "Select between `minSelections` and `maxSelections` of `options`. A yes/no/abstain motion is a choice of exactly one of three.",
/// "type": "object",
/// "required": [
/// "key",
/// "maxSelections",
/// "minSelections",
/// "optional",
/// "options",
/// "type"
/// ],
/// "properties": {
/// "key": {
/// "$ref": "#/definitions/Key"
/// },
/// "maxSelections": {
/// "type": "integer",
/// "minimum": 1.0
/// },
/// "minSelections": {
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "optional": {
/// "type": "boolean"
/// },
/// "options": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/QuestionOption"
/// },
/// "maxItems": 256,
/// "minItems": 2
/// },
/// "text": {
/// "type": "string",
/// "maxLength": 2048
/// },
/// "type": {
/// "const": "choice"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "RankingQuestion",
/// "description": "Order `options`; a ballot ranks every option or, when `partial` is true, a prefix of them.",
/// "type": "object",
/// "required": [
/// "key",
/// "optional",
/// "options",
/// "partial",
/// "type"
/// ],
/// "properties": {
/// "key": {
/// "$ref": "#/definitions/Key"
/// },
/// "optional": {
/// "type": "boolean"
/// },
/// "options": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/QuestionOption"
/// },
/// "maxItems": 64,
/// "minItems": 2
/// },
/// "partial": {
/// "type": "boolean"
/// },
/// "text": {
/// "type": "string",
/// "maxLength": 2048
/// },
/// "type": {
/// "const": "ranking"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "ScoreQuestion",
/// "description": "Give each option an integer score within [min, max].",
/// "type": "object",
/// "required": [
/// "key",
/// "max",
/// "min",
/// "optional",
/// "options",
/// "type"
/// ],
/// "properties": {
/// "key": {
/// "$ref": "#/definitions/Key"
/// },
/// "max": {
/// "type": "integer"
/// },
/// "min": {
/// "type": "integer"
/// },
/// "optional": {
/// "type": "boolean"
/// },
/// "options": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/QuestionOption"
/// },
/// "maxItems": 256,
/// "minItems": 1
/// },
/// "text": {
/// "type": "string",
/// "maxLength": 2048
/// },
/// "type": {
/// "const": "score"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "TextQuestion",
/// "description": "Free text of at most `maxLength` characters.",
/// "type": "object",
/// "required": [
/// "key",
/// "maxLength",
/// "optional",
/// "type"
/// ],
/// "properties": {
/// "key": {
/// "$ref": "#/definitions/Key"
/// },
/// "maxLength": {
/// "type": "integer",
/// "maximum": 4096.0,
/// "minimum": 1.0
/// },
/// "optional": {
/// "type": "boolean"
/// },
/// "text": {
/// "type": "string",
/// "maxLength": 2048
/// },
/// "type": {
/// "const": "text"
/// }
/// },
/// "additionalProperties": false
/// }
/// ]
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(tag = "type", deny_unknown_fields)]
#[non_exhaustive]
pub enum Question {
/**
ChoiceQuestion
Select between `minSelections` and `maxSelections` of `options`. A yes/no/abstain motion is a choice of exactly one of three.*/
#[serde(rename = "choice")]
Choice {
key: Key,
#[serde(rename = "maxSelections")]
max_selections: ::std::num::NonZeroU64,
#[serde(rename = "minSelections")]
min_selections: u64,
optional: bool,
options: ::std::vec::Vec<QuestionOption>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
text: ::std::option::Option<QuestionText>,
},
/**
RankingQuestion
Order `options`; a ballot ranks every option or, when `partial` is true, a prefix of them.*/
#[serde(rename = "ranking")]
Ranking {
key: Key,
optional: bool,
options: ::std::vec::Vec<QuestionOption>,
partial: bool,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
text: ::std::option::Option<QuestionText>,
},
/**
ScoreQuestion
Give each option an integer score within [min, max].*/
#[serde(rename = "score")]
Score {
key: Key,
max: i64,
min: i64,
optional: bool,
options: ::std::vec::Vec<QuestionOption>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
text: ::std::option::Option<QuestionText>,
},
/**
TextQuestion
Free text of at most `maxLength` characters.*/
#[serde(rename = "text")]
Text {
key: Key,
#[serde(rename = "maxLength")]
max_length: ::std::num::NonZeroU64,
optional: bool,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
text: ::std::option::Option<QuestionText>,
},
}
///`QuestionOption`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "QuestionOption",
/// "type": "object",
/// "required": [
/// "key"
/// ],
/// "properties": {
/// "key": {
/// "$ref": "#/definitions/Key"
/// },
/// "label": {
/// "description": "Display text. Absent from a manifest registered with a ballot box that holds no question text (VTI-VOT-014).",
/// "type": "string",
/// "maxLength": 512
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct QuestionOption {
pub key: Key,
///Display text. Absent from a manifest registered with a ballot box that holds no question text (VTI-VOT-014).
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub label: ::std::option::Option<QuestionOptionLabel>,
}
impl QuestionOption {
pub fn builder() -> builder::QuestionOption {
Default::default()
}
}
///Display text. Absent from a manifest registered with a ballot box that holds no question text (VTI-VOT-014).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Display text. Absent from a manifest registered with a ballot box that holds no question text (VTI-VOT-014).",
/// "type": "string",
/// "maxLength": 512
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct QuestionOptionLabel(::std::string::String);
impl ::std::ops::Deref for QuestionOptionLabel {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<QuestionOptionLabel> for ::std::string::String {
fn from(value: QuestionOptionLabel) -> Self {
value.0
}
}
impl ::std::str::FromStr for QuestionOptionLabel {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 512usize {
return Err("longer than 512 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for QuestionOptionLabel {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for QuestionOptionLabel {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for QuestionOptionLabel {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for QuestionOptionLabel {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`QuestionText`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 2048
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct QuestionText(::std::string::String);
impl ::std::ops::Deref for QuestionText {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<QuestionText> for ::std::string::String {
fn from(value: QuestionText) -> Self {
value.0
}
}
impl ::std::str::FromStr for QuestionText {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for QuestionText {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for QuestionText {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for QuestionText {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for QuestionText {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`Response`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "type": "object",
/// "required": [
/// "castDocument",
/// "tag"
/// ],
/// "properties": {
/// "castDocument": {
/// "title": "CastDocument",
/// "description": "The voting/ballot/cast-encrypted request, signed by a key made for this cast alone (VTI-VOT-003).",
/// "type": "object",
/// "required": [
/// "id",
/// "issuedAt",
/// "issuer",
/// "payload",
/// "proof",
/// "recipient",
/// "type"
/// ],
/// "properties": {
/// "expiresAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "id": {
/// "type": "string",
/// "pattern": "^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
/// },
/// "issuedAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "issuer": {
/// "description": "The signer.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "payload": {
/// "description": "That task's request payload.",
/// "type": "object"
/// },
/// "proof": {
/// "description": "A Data Integrity proof by an `authentication` key of `issuer`.",
/// "type": "object"
/// },
/// "recipient": {
/// "description": "The ballot box.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "type": {
/// "const": "https://trusttasks.org/spec/voting/ballot/cast-encrypted/0.1"
/// }
/// }
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "tag": {
/// "$ref": "#/definitions/Multibase"
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
#[serde(rename = "castDocument")]
pub cast_document: CastDocument,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
pub tag: Multibase,
}
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 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 Answer {
abstain: ::std::result::Result<
::std::option::Option<::serde_json::Value>,
::std::string::String,
>,
choice:
::std::result::Result<::std::option::Option<Vec<super::Key>>, ::std::string::String>,
question: ::std::result::Result<super::Key, ::std::string::String>,
ranking:
::std::result::Result<::std::option::Option<Vec<super::Key>>, ::std::string::String>,
scores: ::std::result::Result<
::std::collections::HashMap<super::Key, i64>,
::std::string::String,
>,
text:
::std::result::Result<::std::option::Option<super::AnswerText>, ::std::string::String>,
}
impl ::std::default::Default for Answer {
fn default() -> Self {
Self {
abstain: Ok(Default::default()),
choice: Ok(Default::default()),
question: Err("no value supplied for question".to_string()),
ranking: Ok(Default::default()),
scores: Ok(Default::default()),
text: Ok(Default::default()),
}
}
}
impl Answer {
pub fn abstain<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::serde_json::Value>>,
T::Error: ::std::fmt::Display,
{
self.abstain = value
.try_into()
.map_err(|e| format!("error converting supplied value for abstain: {e}"));
self
}
pub fn choice<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<Vec<super::Key>>>,
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::option::Option<Vec<super::Key>>>,
T::Error: ::std::fmt::Display,
{
self.ranking = value
.try_into()
.map_err(|e| format!("error converting supplied value for ranking: {e}"));
self
}
pub fn scores<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::collections::HashMap<super::Key, i64>>,
T::Error: ::std::fmt::Display,
{
self.scores = value
.try_into()
.map_err(|e| format!("error converting supplied value for scores: {e}"));
self
}
pub fn text<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::AnswerText>>,
T::Error: ::std::fmt::Display,
{
self.text = value
.try_into()
.map_err(|e| format!("error converting supplied value for text: {e}"));
self
}
}
impl ::std::convert::TryFrom<Answer> for super::Answer {
type Error = super::error::ConversionError;
fn try_from(value: Answer) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
abstain: value.abstain?,
choice: value.choice?,
question: value.question?,
ranking: value.ranking?,
scores: value.scores?,
text: value.text?,
})
}
}
impl ::std::convert::From<super::Answer> for Answer {
fn from(value: super::Answer) -> Self {
Self {
abstain: Ok(value.abstain),
choice: Ok(value.choice),
question: Ok(value.question),
ranking: Ok(value.ranking),
scores: Ok(value.scores),
text: Ok(value.text),
}
}
}
#[derive(Clone, Debug)]
pub struct Ballot {
answers: ::std::result::Result<::std::vec::Vec<super::Answer>, ::std::string::String>,
election_id: ::std::result::Result<super::ElectionId, ::std::string::String>,
manifest_digest: ::std::result::Result<super::DigestMultibase, ::std::string::String>,
}
impl ::std::default::Default for Ballot {
fn default() -> Self {
Self {
answers: Err("no value supplied for answers".to_string()),
election_id: Err("no value supplied for election_id".to_string()),
manifest_digest: Err("no value supplied for manifest_digest".to_string()),
}
}
}
impl Ballot {
pub fn answers<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::Answer>>,
T::Error: ::std::fmt::Display,
{
self.answers = value
.try_into()
.map_err(|e| format!("error converting supplied value for answers: {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 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
}
}
impl ::std::convert::TryFrom<Ballot> for super::Ballot {
type Error = super::error::ConversionError;
fn try_from(value: Ballot) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
answers: value.answers?,
election_id: value.election_id?,
manifest_digest: value.manifest_digest?,
})
}
}
impl ::std::convert::From<super::Ballot> for Ballot {
fn from(value: super::Ballot) -> Self {
Self {
answers: Ok(value.answers),
election_id: Ok(value.election_id),
manifest_digest: Ok(value.manifest_digest),
}
}
}
#[derive(Clone, Debug)]
pub struct CastDocument {
expires_at: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
id: ::std::result::Result<super::CastDocumentId, ::std::string::String>,
issued_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
issuer: ::std::result::Result<super::CastDocumentIssuer, ::std::string::String>,
payload: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
proof: ::std::result::Result<
::serde_json::Map<::std::string::String, ::serde_json::Value>,
::std::string::String,
>,
recipient: ::std::result::Result<super::CastDocumentRecipient, ::std::string::String>,
type_: ::std::result::Result<::serde_json::Value, ::std::string::String>,
}
impl ::std::default::Default for CastDocument {
fn default() -> Self {
Self {
expires_at: Ok(Default::default()),
id: Err("no value supplied for id".to_string()),
issued_at: Err("no value supplied for issued_at".to_string()),
issuer: Err("no value supplied for issuer".to_string()),
payload: Err("no value supplied for payload".to_string()),
proof: Err("no value supplied for proof".to_string()),
recipient: Err("no value supplied for recipient".to_string()),
type_: Err("no value supplied for type_".to_string()),
}
}
}
impl CastDocument {
pub fn expires_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
>,
T::Error: ::std::fmt::Display,
{
self.expires_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for expires_at: {e}"));
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::CastDocumentId>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for 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 issuer<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::CastDocumentIssuer>,
T::Error: ::std::fmt::Display,
{
self.issuer = value
.try_into()
.map_err(|e| format!("error converting supplied value for issuer: {e}"));
self
}
pub fn payload<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.payload = value
.try_into()
.map_err(|e| format!("error converting supplied value for payload: {e}"));
self
}
pub fn proof<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.proof = value
.try_into()
.map_err(|e| format!("error converting supplied value for proof: {e}"));
self
}
pub fn recipient<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::CastDocumentRecipient>,
T::Error: ::std::fmt::Display,
{
self.recipient = value
.try_into()
.map_err(|e| format!("error converting supplied value for recipient: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::serde_json::Value>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<CastDocument> for super::CastDocument {
type Error = super::error::ConversionError;
fn try_from(
value: CastDocument,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
expires_at: value.expires_at?,
id: value.id?,
issued_at: value.issued_at?,
issuer: value.issuer?,
payload: value.payload?,
proof: value.proof?,
recipient: value.recipient?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::CastDocument> for CastDocument {
fn from(value: super::CastDocument) -> Self {
Self {
expires_at: Ok(value.expires_at),
id: Ok(value.id),
issued_at: Ok(value.issued_at),
issuer: Ok(value.issuer),
payload: Ok(value.payload),
proof: Ok(value.proof),
recipient: Ok(value.recipient),
type_: Ok(value.type_),
}
}
}
#[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 Manifest {
allow_early_close: ::std::result::Result<bool, ::std::string::String>,
ballot_box: ::std::result::Result<super::ManifestBallotBox, ::std::string::String>,
binding: ::std::result::Result<bool, ::std::string::String>,
board: ::std::result::Result<super::ManifestBoard, ::std::string::String>,
community: ::std::result::Result<super::ManifestCommunity, ::std::string::String>,
description: ::std::result::Result<
::std::option::Option<super::ManifestDescription>,
::std::string::String,
>,
election_id: ::std::result::Result<super::ElectionId, ::std::string::String>,
questions: ::std::result::Result<::std::vec::Vec<super::Question>, ::std::string::String>,
registration_opens:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
results_before_close: ::std::result::Result<bool, ::std::string::String>,
revote: ::std::result::Result<super::Revote, ::std::string::String>,
roll: ::std::result::Result<super::RollRule, ::std::string::String>,
secrecy: ::std::result::Result<super::SecrecyLevel, ::std::string::String>,
text_release_threshold: ::std::result::Result<i64, ::std::string::String>,
title: ::std::result::Result<
::std::option::Option<super::ManifestTitle>,
::std::string::String,
>,
trustees:
::std::result::Result<::std::option::Option<super::Trustees>, ::std::string::String>,
voting_closes:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
voting_opens:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
}
impl ::std::default::Default for Manifest {
fn default() -> Self {
Self {
allow_early_close: Err("no value supplied for allow_early_close".to_string()),
ballot_box: Err("no value supplied for ballot_box".to_string()),
binding: Err("no value supplied for binding".to_string()),
board: Err("no value supplied for board".to_string()),
community: Err("no value supplied for community".to_string()),
description: Ok(Default::default()),
election_id: Err("no value supplied for election_id".to_string()),
questions: Err("no value supplied for questions".to_string()),
registration_opens: Err("no value supplied for registration_opens".to_string()),
results_before_close: Err("no value supplied for results_before_close".to_string()),
revote: Err("no value supplied for revote".to_string()),
roll: Err("no value supplied for roll".to_string()),
secrecy: Err("no value supplied for secrecy".to_string()),
text_release_threshold: Err(
"no value supplied for text_release_threshold".to_string()
),
title: Ok(Default::default()),
trustees: Ok(Default::default()),
voting_closes: Err("no value supplied for voting_closes".to_string()),
voting_opens: Err("no value supplied for voting_opens".to_string()),
}
}
}
impl Manifest {
pub fn allow_early_close<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.allow_early_close = value
.try_into()
.map_err(|e| format!("error converting supplied value for allow_early_close: {e}"));
self
}
pub fn ballot_box<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ManifestBallotBox>,
T::Error: ::std::fmt::Display,
{
self.ballot_box = value
.try_into()
.map_err(|e| format!("error converting supplied value for ballot_box: {e}"));
self
}
pub fn binding<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.binding = value
.try_into()
.map_err(|e| format!("error converting supplied value for binding: {e}"));
self
}
pub fn board<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ManifestBoard>,
T::Error: ::std::fmt::Display,
{
self.board = value
.try_into()
.map_err(|e| format!("error converting supplied value for board: {e}"));
self
}
pub fn community<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ManifestCommunity>,
T::Error: ::std::fmt::Display,
{
self.community = value
.try_into()
.map_err(|e| format!("error converting supplied value for community: {e}"));
self
}
pub fn description<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ManifestDescription>>,
T::Error: ::std::fmt::Display,
{
self.description = value
.try_into()
.map_err(|e| format!("error converting supplied value for description: {e}"));
self
}
pub fn election_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElectionId>,
T::Error: ::std::fmt::Display,
{
self.election_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for election_id: {e}"));
self
}
pub fn questions<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::Question>>,
T::Error: ::std::fmt::Display,
{
self.questions = value
.try_into()
.map_err(|e| format!("error converting supplied value for questions: {e}"));
self
}
pub fn registration_opens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.registration_opens = value.try_into().map_err(|e| {
format!("error converting supplied value for registration_opens: {e}")
});
self
}
pub fn results_before_close<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.results_before_close = value.try_into().map_err(|e| {
format!("error converting supplied value for results_before_close: {e}")
});
self
}
pub fn revote<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Revote>,
T::Error: ::std::fmt::Display,
{
self.revote = value
.try_into()
.map_err(|e| format!("error converting supplied value for revote: {e}"));
self
}
pub fn roll<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::RollRule>,
T::Error: ::std::fmt::Display,
{
self.roll = value
.try_into()
.map_err(|e| format!("error converting supplied value for roll: {e}"));
self
}
pub fn secrecy<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::SecrecyLevel>,
T::Error: ::std::fmt::Display,
{
self.secrecy = value
.try_into()
.map_err(|e| format!("error converting supplied value for secrecy: {e}"));
self
}
pub fn text_release_threshold<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<i64>,
T::Error: ::std::fmt::Display,
{
self.text_release_threshold = value.try_into().map_err(|e| {
format!("error converting supplied value for text_release_threshold: {e}")
});
self
}
pub fn title<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ManifestTitle>>,
T::Error: ::std::fmt::Display,
{
self.title = value
.try_into()
.map_err(|e| format!("error converting supplied value for title: {e}"));
self
}
pub fn trustees<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Trustees>>,
T::Error: ::std::fmt::Display,
{
self.trustees = value
.try_into()
.map_err(|e| format!("error converting supplied value for trustees: {e}"));
self
}
pub fn voting_closes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.voting_closes = value
.try_into()
.map_err(|e| format!("error converting supplied value for voting_closes: {e}"));
self
}
pub fn voting_opens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.voting_opens = value
.try_into()
.map_err(|e| format!("error converting supplied value for voting_opens: {e}"));
self
}
}
impl ::std::convert::TryFrom<Manifest> for super::Manifest {
type Error = super::error::ConversionError;
fn try_from(value: Manifest) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
allow_early_close: value.allow_early_close?,
ballot_box: value.ballot_box?,
binding: value.binding?,
board: value.board?,
community: value.community?,
description: value.description?,
election_id: value.election_id?,
questions: value.questions?,
registration_opens: value.registration_opens?,
results_before_close: value.results_before_close?,
revote: value.revote?,
roll: value.roll?,
secrecy: value.secrecy?,
text_release_threshold: value.text_release_threshold?,
title: value.title?,
trustees: value.trustees?,
voting_closes: value.voting_closes?,
voting_opens: value.voting_opens?,
})
}
}
impl ::std::convert::From<super::Manifest> for Manifest {
fn from(value: super::Manifest) -> Self {
Self {
allow_early_close: Ok(value.allow_early_close),
ballot_box: Ok(value.ballot_box),
binding: Ok(value.binding),
board: Ok(value.board),
community: Ok(value.community),
description: Ok(value.description),
election_id: Ok(value.election_id),
questions: Ok(value.questions),
registration_opens: Ok(value.registration_opens),
results_before_close: Ok(value.results_before_close),
revote: Ok(value.revote),
roll: Ok(value.roll),
secrecy: Ok(value.secrecy),
text_release_threshold: Ok(value.text_release_threshold),
title: Ok(value.title),
trustees: Ok(value.trustees),
voting_closes: Ok(value.voting_closes),
voting_opens: Ok(value.voting_opens),
}
}
}
#[derive(Clone, Debug)]
pub struct ManifestBoard {
auditors:
::std::result::Result<Vec<super::ManifestBoardAuditorsItem>, ::std::string::String>,
visibility: ::std::result::Result<super::BoardVisibility, ::std::string::String>,
}
impl ::std::default::Default for ManifestBoard {
fn default() -> Self {
Self {
auditors: Err("no value supplied for auditors".to_string()),
visibility: Err("no value supplied for visibility".to_string()),
}
}
}
impl ManifestBoard {
pub fn auditors<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<Vec<super::ManifestBoardAuditorsItem>>,
T::Error: ::std::fmt::Display,
{
self.auditors = value
.try_into()
.map_err(|e| format!("error converting supplied value for auditors: {e}"));
self
}
pub fn visibility<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::BoardVisibility>,
T::Error: ::std::fmt::Display,
{
self.visibility = value
.try_into()
.map_err(|e| format!("error converting supplied value for visibility: {e}"));
self
}
}
impl ::std::convert::TryFrom<ManifestBoard> for super::ManifestBoard {
type Error = super::error::ConversionError;
fn try_from(
value: ManifestBoard,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
auditors: value.auditors?,
visibility: value.visibility?,
})
}
}
impl ::std::convert::From<super::ManifestBoard> for ManifestBoard {
fn from(value: super::ManifestBoard) -> Self {
Self {
auditors: Ok(value.auditors),
visibility: Ok(value.visibility),
}
}
}
#[derive(Clone, Debug)]
pub struct Payload {
ballot: ::std::result::Result<super::Ballot, ::std::string::String>,
community: ::std::result::Result<super::PayloadCommunity, ::std::string::String>,
context_id: ::std::result::Result<super::PayloadContextId, ::std::string::String>,
election_key: ::std::result::Result<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>,
parameters: ::std::result::Result<super::VotingParameters, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
ballot: Err("no value supplied for ballot".to_string()),
community: Err("no value supplied for community".to_string()),
context_id: Err("no value supplied for context_id".to_string()),
election_key: Err("no value supplied for election_key".to_string()),
ext: Ok(Default::default()),
manifest: Err("no value supplied for manifest".to_string()),
parameters: Err("no value supplied for parameters".to_string()),
}
}
}
impl Payload {
pub fn ballot<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Ballot>,
T::Error: ::std::fmt::Display,
{
self.ballot = value
.try_into()
.map_err(|e| format!("error converting supplied value for ballot: {e}"));
self
}
pub fn community<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadCommunity>,
T::Error: ::std::fmt::Display,
{
self.community = value
.try_into()
.map_err(|e| format!("error converting supplied value for community: {e}"));
self
}
pub fn context_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadContextId>,
T::Error: ::std::fmt::Display,
{
self.context_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for context_id: {e}"));
self
}
pub fn election_key<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<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 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
}
}
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 {
ballot: value.ballot?,
community: value.community?,
context_id: value.context_id?,
election_key: value.election_key?,
ext: value.ext?,
manifest: value.manifest?,
parameters: value.parameters?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
ballot: Ok(value.ballot),
community: Ok(value.community),
context_id: Ok(value.context_id),
election_key: Ok(value.election_key),
ext: Ok(value.ext),
manifest: Ok(value.manifest),
parameters: Ok(value.parameters),
}
}
}
#[derive(Clone, Debug)]
pub struct QuestionOption {
key: ::std::result::Result<super::Key, ::std::string::String>,
label: ::std::result::Result<
::std::option::Option<super::QuestionOptionLabel>,
::std::string::String,
>,
}
impl ::std::default::Default for QuestionOption {
fn default() -> Self {
Self {
key: Err("no value supplied for key".to_string()),
label: Ok(Default::default()),
}
}
}
impl QuestionOption {
pub fn key<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Key>,
T::Error: ::std::fmt::Display,
{
self.key = value
.try_into()
.map_err(|e| format!("error converting supplied value for key: {e}"));
self
}
pub fn label<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::QuestionOptionLabel>>,
T::Error: ::std::fmt::Display,
{
self.label = value
.try_into()
.map_err(|e| format!("error converting supplied value for label: {e}"));
self
}
}
impl ::std::convert::TryFrom<QuestionOption> for super::QuestionOption {
type Error = super::error::ConversionError;
fn try_from(
value: QuestionOption,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
key: value.key?,
label: value.label?,
})
}
}
impl ::std::convert::From<super::QuestionOption> for QuestionOption {
fn from(value: super::QuestionOption) -> Self {
Self {
key: Ok(value.key),
label: Ok(value.label),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
cast_document: ::std::result::Result<super::CastDocument, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
tag: ::std::result::Result<super::Multibase, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
cast_document: Err("no value supplied for cast_document".to_string()),
ext: Ok(Default::default()),
tag: Err("no value supplied for tag".to_string()),
}
}
}
impl Response {
pub fn cast_document<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::CastDocument>,
T::Error: ::std::fmt::Display,
{
self.cast_document = value
.try_into()
.map_err(|e| format!("error converting supplied value for cast_document: {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 tag<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Multibase>,
T::Error: ::std::fmt::Display,
{
self.tag = value
.try_into()
.map_err(|e| format!("error converting supplied value for tag: {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 {
cast_document: value.cast_document?,
ext: value.ext?,
tag: value.tag?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
cast_document: Ok(value.cast_document),
ext: Ok(value.ext),
tag: Ok(value.tag),
}
}
}
#[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/vta/pcs/vote-encrypted/0.1";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"Answer\": {\n \"additionalProperties\": false,\n \"description\": \"The answer to one question. Exactly one member besides `question` is present, matching the question's type, or `abstain` for an optional question left unanswered.\",\n \"maxProperties\": 2,\n \"minProperties\": 2,\n \"properties\": {\n \"abstain\": {\n \"const\": true\n },\n \"choice\": {\n \"items\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"question\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"ranking\": {\n \"items\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"scores\": {\n \"additionalProperties\": {\n \"type\": \"integer\"\n },\n \"propertyNames\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"object\"\n },\n \"text\": {\n \"maxLength\": 4096,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"question\"\n ],\n \"title\": \"Answer\",\n \"type\": \"object\"\n },\n \"Ballot\": {\n \"additionalProperties\": false,\n \"description\": \"An open ballot: one answer per question of the manifest, in any order. The bytes a cast's proof binds are the RFC 8785 (JCS) canonicalization of this object as received.\",\n \"properties\": {\n \"answers\": {\n \"items\": {\n \"$ref\": \"#/$defs/Answer\"\n },\n \"maxItems\": 128,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"manifestDigest\": {\n \"$ref\": \"#/$defs/DigestMultibase\"\n }\n },\n \"required\": [\n \"electionId\",\n \"manifestDigest\",\n \"answers\"\n ],\n \"title\": \"Ballot\",\n \"type\": \"object\"\n },\n \"BoardVisibility\": {\n \"description\": \"`public`: anyone reads the board. `private`: the community, the auditors the manifest names and, for one cast's inclusion, the holder of its receipt (VTI-VOT-052).\",\n \"enum\": [\n \"public\",\n \"private\"\n ],\n \"title\": \"BoardVisibility\",\n \"type\": \"string\"\n },\n \"DigestMultibase\": {\n \"description\": \"A cryptographic digest as a multibase-encoded multihash — the encoding the W3C Verifiable Credentials Data Model 2.0 defines for `digestMultibase`, and the one `did:webvh` uses for its SCID and entry hashes.\\n\\nMultihash carries the hash algorithm in-band, so the value is self-describing and the wire format survives an algorithm change without a schema revision; multibase does the same for the base encoding, so a verifier never infers base58 from base64url by context. A bare hex string or a `sha-256:`-style prefix hard-codes one algorithm into the wire contract and is non-conforming here.\\n\\nThis definition constrains the *encoding only*. What the digest is computed over is stated by each referencing field, because it differs legitimately: a digest over a JSON document is taken over its RFC 8785 (JCS) canonicalization, while a digest over an opaque artifact is taken over its bytes. A field whose input is a JSON document and which does not name a canonicalization is not reproducible.\\n\\nRestricted to the two multibase headers W3C Controlled Identifiers 1.0 §2.4 normatively requires — `z` (base58btc) and `u` (base64url-no-pad). CID permits others but states that \\\"interoperability is not guaranteed between implementations using such values\\\", and a registry whose purpose is interoperability should not mint digests a conforming verifier may be unable to read. The alphabets are enforced rather than assumed: base58btc excludes 0, O, I and l, and an earlier permissive pattern let three published examples carry digests that were not valid base58 at all. base58btc is RECOMMENDED, for consistency with `did:key` and `did:webvh`.\",\n \"examples\": [\n \"zQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR\"\n ],\n \"minLength\": 16,\n \"pattern\": \"^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$\",\n \"title\": \"DigestMultibase\",\n \"type\": \"string\"\n },\n \"ElectionId\": {\n \"description\": \"An election's identifier, unique within its community. A closed alphabet: it appears in the ticket class label `voter/<electionId>` and is framed into every hash a cast is bound to.\",\n \"pattern\": \"^[A-Za-z0-9._-]{1,128}$\",\n \"title\": \"ElectionId\",\n \"type\": \"string\"\n },\n \"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 \"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 \"registrationOpens\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"resultsBeforeClose\": {\n \"description\": \"Open elections only: whether running totals may be read while voting is open (VTI-VOT-061).\",\n \"type\": \"boolean\"\n },\n \"revote\": {\n \"$ref\": \"#/$defs/Revote\"\n },\n \"roll\": {\n \"$ref\": \"#/$defs/RollRule\"\n },\n \"secrecy\": {\n \"$ref\": \"#/$defs/SecrecyLevel\"\n },\n \"textReleaseThreshold\": {\n \"description\": \"Counted ballots required before any text answer is disclosed (VTI-VOT-065).\",\n \"minimum\": 10,\n \"type\": \"integer\"\n },\n \"title\": {\n \"maxLength\": 512,\n \"type\": \"string\"\n },\n \"trustees\": {\n \"$ref\": \"#/$defs/Trustees\"\n },\n \"votingCloses\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"votingOpens\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"electionId\",\n \"community\",\n \"questions\",\n \"secrecy\",\n \"roll\",\n \"registrationOpens\",\n \"votingOpens\",\n \"votingCloses\",\n \"revote\",\n \"board\",\n \"ballotBox\",\n \"binding\",\n \"allowEarlyClose\",\n \"resultsBeforeClose\",\n \"textReleaseThreshold\"\n ],\n \"title\": \"Manifest\",\n \"type\": \"object\"\n },\n \"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 \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"properties\": {\n \"castDocument\": {\n \"description\": \"The voting/ballot/cast-encrypted request, signed by a key made for this cast alone (VTI-VOT-003).\",\n \"properties\": {\n \"expiresAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"id\": {\n \"pattern\": \"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$\",\n \"type\": \"string\"\n },\n \"issuedAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"issuer\": {\n \"description\": \"The signer.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"payload\": {\n \"description\": \"That task's request payload.\",\n \"type\": \"object\"\n },\n \"proof\": {\n \"description\": \"A Data Integrity proof by an `authentication` key of `issuer`.\",\n \"type\": \"object\"\n },\n \"recipient\": {\n \"description\": \"The ballot box.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"type\": {\n \"const\": \"https://trusttasks.org/spec/voting/ballot/cast-encrypted/0.1\"\n }\n },\n \"required\": [\n \"id\",\n \"type\",\n \"issuer\",\n \"recipient\",\n \"issuedAt\",\n \"payload\",\n \"proof\"\n ],\n \"title\": \"CastDocument\",\n \"type\": \"object\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"tag\": {\n \"$ref\": \"#/$defs/Multibase\"\n }\n },\n \"required\": [\n \"castDocument\",\n \"tag\"\n ],\n \"title\": \"VTA PCS — Vote Encrypted — 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 \"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/vta/pcs/vote-encrypted/0.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"The voter's VTA checks a ballot against the manifest, encrypts it to the election key as the election's level requires, and returns the cast signed by a key made for it alone.\",\n \"properties\": {\n \"ballot\": {\n \"$ref\": \"#/$defs/Ballot\"\n },\n \"community\": {\n \"description\": \"The community's DID.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"contextId\": {\n \"description\": \"The context the voter belongs to.\",\n \"maxLength\": 256,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"electionKey\": {\n \"$ref\": \"#/$defs/ElectionKey\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"manifest\": {\n \"$ref\": \"#/$defs/Manifest\"\n },\n \"parameters\": {\n \"$ref\": \"#/$defs/VotingParameters\"\n }\n },\n \"required\": [\n \"contextId\",\n \"community\",\n \"parameters\",\n \"manifest\",\n \"electionKey\",\n \"ballot\"\n ],\n \"title\": \"VTA PCS — Vote Encrypted — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/vta/pcs/vote-encrypted/0.1#response";
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"Answer\": {\n \"additionalProperties\": false,\n \"description\": \"The answer to one question. Exactly one member besides `question` is present, matching the question's type, or `abstain` for an optional question left unanswered.\",\n \"maxProperties\": 2,\n \"minProperties\": 2,\n \"properties\": {\n \"abstain\": {\n \"const\": true\n },\n \"choice\": {\n \"items\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"question\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"ranking\": {\n \"items\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"scores\": {\n \"additionalProperties\": {\n \"type\": \"integer\"\n },\n \"propertyNames\": {\n \"$ref\": \"#/$defs/Key\"\n },\n \"type\": \"object\"\n },\n \"text\": {\n \"maxLength\": 4096,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"question\"\n ],\n \"title\": \"Answer\",\n \"type\": \"object\"\n },\n \"Ballot\": {\n \"additionalProperties\": false,\n \"description\": \"An open ballot: one answer per question of the manifest, in any order. The bytes a cast's proof binds are the RFC 8785 (JCS) canonicalization of this object as received.\",\n \"properties\": {\n \"answers\": {\n \"items\": {\n \"$ref\": \"#/$defs/Answer\"\n },\n \"maxItems\": 128,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"manifestDigest\": {\n \"$ref\": \"#/$defs/DigestMultibase\"\n }\n },\n \"required\": [\n \"electionId\",\n \"manifestDigest\",\n \"answers\"\n ],\n \"title\": \"Ballot\",\n \"type\": \"object\"\n },\n \"BoardVisibility\": {\n \"description\": \"`public`: anyone reads the board. `private`: the community, the auditors the manifest names and, for one cast's inclusion, the holder of its receipt (VTI-VOT-052).\",\n \"enum\": [\n \"public\",\n \"private\"\n ],\n \"title\": \"BoardVisibility\",\n \"type\": \"string\"\n },\n \"DigestMultibase\": {\n \"description\": \"A cryptographic digest as a multibase-encoded multihash — the encoding the W3C Verifiable Credentials Data Model 2.0 defines for `digestMultibase`, and the one `did:webvh` uses for its SCID and entry hashes.\\n\\nMultihash carries the hash algorithm in-band, so the value is self-describing and the wire format survives an algorithm change without a schema revision; multibase does the same for the base encoding, so a verifier never infers base58 from base64url by context. A bare hex string or a `sha-256:`-style prefix hard-codes one algorithm into the wire contract and is non-conforming here.\\n\\nThis definition constrains the *encoding only*. What the digest is computed over is stated by each referencing field, because it differs legitimately: a digest over a JSON document is taken over its RFC 8785 (JCS) canonicalization, while a digest over an opaque artifact is taken over its bytes. A field whose input is a JSON document and which does not name a canonicalization is not reproducible.\\n\\nRestricted to the two multibase headers W3C Controlled Identifiers 1.0 §2.4 normatively requires — `z` (base58btc) and `u` (base64url-no-pad). CID permits others but states that \\\"interoperability is not guaranteed between implementations using such values\\\", and a registry whose purpose is interoperability should not mint digests a conforming verifier may be unable to read. The alphabets are enforced rather than assumed: base58btc excludes 0, O, I and l, and an earlier permissive pattern let three published examples carry digests that were not valid base58 at all. base58btc is RECOMMENDED, for consistency with `did:key` and `did:webvh`.\",\n \"examples\": [\n \"zQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR\"\n ],\n \"minLength\": 16,\n \"pattern\": \"^(z[1-9A-HJ-NP-Za-km-z]+|u[A-Za-z0-9_-]+)$\",\n \"title\": \"DigestMultibase\",\n \"type\": \"string\"\n },\n \"ElectionId\": {\n \"description\": \"An election's identifier, unique within its community. A closed alphabet: it appears in the ticket class label `voter/<electionId>` and is framed into every hash a cast is bound to.\",\n \"pattern\": \"^[A-Za-z0-9._-]{1,128}$\",\n \"title\": \"ElectionId\",\n \"type\": \"string\"\n },\n \"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 \"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 \"registrationOpens\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"resultsBeforeClose\": {\n \"description\": \"Open elections only: whether running totals may be read while voting is open (VTI-VOT-061).\",\n \"type\": \"boolean\"\n },\n \"revote\": {\n \"$ref\": \"#/$defs/Revote\"\n },\n \"roll\": {\n \"$ref\": \"#/$defs/RollRule\"\n },\n \"secrecy\": {\n \"$ref\": \"#/$defs/SecrecyLevel\"\n },\n \"textReleaseThreshold\": {\n \"description\": \"Counted ballots required before any text answer is disclosed (VTI-VOT-065).\",\n \"minimum\": 10,\n \"type\": \"integer\"\n },\n \"title\": {\n \"maxLength\": 512,\n \"type\": \"string\"\n },\n \"trustees\": {\n \"$ref\": \"#/$defs/Trustees\"\n },\n \"votingCloses\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"votingOpens\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"electionId\",\n \"community\",\n \"questions\",\n \"secrecy\",\n \"roll\",\n \"registrationOpens\",\n \"votingOpens\",\n \"votingCloses\",\n \"revote\",\n \"board\",\n \"ballotBox\",\n \"binding\",\n \"allowEarlyClose\",\n \"resultsBeforeClose\",\n \"textReleaseThreshold\"\n ],\n \"title\": \"Manifest\",\n \"type\": \"object\"\n },\n \"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 \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"properties\": {\n \"castDocument\": {\n \"description\": \"The voting/ballot/cast-encrypted request, signed by a key made for this cast alone (VTI-VOT-003).\",\n \"properties\": {\n \"expiresAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"id\": {\n \"pattern\": \"^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$\",\n \"type\": \"string\"\n },\n \"issuedAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"issuer\": {\n \"description\": \"The signer.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"payload\": {\n \"description\": \"That task's request payload.\",\n \"type\": \"object\"\n },\n \"proof\": {\n \"description\": \"A Data Integrity proof by an `authentication` key of `issuer`.\",\n \"type\": \"object\"\n },\n \"recipient\": {\n \"description\": \"The ballot box.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"type\": {\n \"const\": \"https://trusttasks.org/spec/voting/ballot/cast-encrypted/0.1\"\n }\n },\n \"required\": [\n \"id\",\n \"type\",\n \"issuer\",\n \"recipient\",\n \"issuedAt\",\n \"payload\",\n \"proof\"\n ],\n \"title\": \"CastDocument\",\n \"type\": \"object\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"tag\": {\n \"$ref\": \"#/$defs/Multibase\"\n }\n },\n \"required\": [\n \"castDocument\",\n \"tag\"\n ],\n \"title\": \"VTA PCS — Vote Encrypted — 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 \"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::NOT_FOUND,
error_codes::WRONG_LEVEL,
error_codes::ELECTION_KEY_INVALID,
error_codes::BALLOT_INVALID,
error_codes::NOT_OPEN,
];
/// 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 {
/// `vta/pcs/vote-encrypted:notFound`
///
/// The engine holds no ticket for this election.
///
/// Declared `retryable: false`.
pub const NOT_FOUND: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/pcs/vote-encrypted:notFound",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vta/pcs/vote-encrypted:wrongLevel`
///
/// The manifest's level is open: use vta/pcs/vote.
///
/// Declared `retryable: false`.
pub const WRONG_LEVEL: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/pcs/vote-encrypted:wrongLevel",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vta/pcs/vote-encrypted:electionKeyInvalid`
///
/// The election key does not hold together, or names other trustees than the manifest.
///
/// Declared `retryable: false`.
pub const ELECTION_KEY_INVALID: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/pcs/vote-encrypted:electionKeyInvalid",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vta/pcs/vote-encrypted:ballotInvalid`
///
/// The ballot does not answer the manifest, or a tallied-encrypted ballot asks a question that is not a choice.
///
/// Declared `retryable: false`.
pub const BALLOT_INVALID: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/pcs/vote-encrypted:ballotInvalid",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vta/pcs/vote-encrypted:notOpen`
///
/// Voting is not open.
///
/// Declared `retryable: false`.
pub const NOT_OPEN: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/pcs/vote-encrypted:notOpen",
retryable: false,
details_schema: ::core::option::Option::None,
};
}