//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vta/pcs/trustee/justify`. Version: `0.3`.
#[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())
}
}
}
///`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()
}
}
///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())
})
}
}
///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())
})
}
}
///The voting/trustees/justify request, signed as the trustee.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "JustifyDocument",
/// "description": "The voting/trustees/justify request, signed as the trustee.",
/// "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/trustees/justify/0.1"
/// }
/// }
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[non_exhaustive]
pub struct JustifyDocument {
#[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: JustifyDocumentId,
#[serde(rename = "issuedAt")]
pub issued_at: ::chrono::DateTime<::chrono::offset::Utc>,
///The signer.
pub issuer: JustifyDocumentIssuer,
///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: JustifyDocumentRecipient,
#[serde(rename = "type")]
pub type_: ::serde_json::Value,
}
impl JustifyDocument {
pub fn builder() -> builder::JustifyDocument {
Default::default()
}
}
///`JustifyDocumentId`
///
/// <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 JustifyDocumentId(::std::string::String);
impl ::std::ops::Deref for JustifyDocumentId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<JustifyDocumentId> for ::std::string::String {
fn from(value: JustifyDocumentId) -> Self {
value.0
}
}
impl ::std::str::FromStr for JustifyDocumentId {
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 JustifyDocumentId {
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 JustifyDocumentId {
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 JustifyDocumentId {
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 JustifyDocumentId {
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 JustifyDocumentIssuer(::std::string::String);
impl ::std::ops::Deref for JustifyDocumentIssuer {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<JustifyDocumentIssuer> for ::std::string::String {
fn from(value: JustifyDocumentIssuer) -> Self {
value.0
}
}
impl ::std::str::FromStr for JustifyDocumentIssuer {
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 JustifyDocumentIssuer {
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 JustifyDocumentIssuer {
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 JustifyDocumentIssuer {
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 JustifyDocumentIssuer {
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 JustifyDocumentRecipient(::std::string::String);
impl ::std::ops::Deref for JustifyDocumentRecipient {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<JustifyDocumentRecipient> for ::std::string::String {
fn from(value: JustifyDocumentRecipient) -> Self {
value.0
}
}
impl ::std::str::FromStr for JustifyDocumentRecipient {
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 JustifyDocumentRecipient {
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 JustifyDocumentRecipient {
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 JustifyDocumentRecipient {
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 JustifyDocumentRecipient {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///A question or option key, unique within its manifest or question.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Key",
/// "description": "A question or option key, unique within its manifest or question.",
/// "type": "string",
/// "pattern": "^[A-Za-z0-9._-]{1,64}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct Key(::std::string::String);
impl ::std::ops::Deref for Key {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<Key> for ::std::string::String {
fn from(value: Key) -> Self {
value.0
}
}
impl ::std::str::FromStr for Key {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| ::regress::Regex::new("^[A-Za-z0-9._-]{1,64}$").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[A-Za-z0-9._-]{1,64}$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for Key {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for Key {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for Key {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for Key {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///What an election asks and how it is decided (VTI-VOT-010). Its digest (`manifestDigest`) is the SHA-256 multihash of its RFC 8785 (JCS) canonicalization, and every cast is bound to it (VTI-VOT-011).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Manifest",
/// "description": "What an election asks and how it is decided (VTI-VOT-010). Its digest (`manifestDigest`) is the SHA-256 multihash of its RFC 8785 (JCS) canonicalization, and every cast is bound to it (VTI-VOT-011).",
/// "type": "object",
/// "required": [
/// "allowEarlyClose",
/// "ballotBox",
/// "binding",
/// "board",
/// "community",
/// "electionId",
/// "questions",
/// "registrationOpensAt",
/// "resultsBeforeClose",
/// "revote",
/// "roll",
/// "secrecy",
/// "textReleaseThreshold",
/// "votingClosesAt",
/// "votingOpensAt"
/// ],
/// "properties": {
/// "allowEarlyClose": {
/// "type": "boolean"
/// },
/// "ballotBox": {
/// "description": "The DID of the voting service that holds the board.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "binding": {
/// "description": "Whether the community treats the result as deciding something; creating a binding election takes another administrator's consent (VTI-VOT-081).",
/// "type": "boolean"
/// },
/// "board": {
/// "type": "object",
/// "required": [
/// "auditors",
/// "visibility"
/// ],
/// "properties": {
/// "auditors": {
/// "type": "array",
/// "items": {
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "uniqueItems": true
/// },
/// "visibility": {
/// "$ref": "#/definitions/BoardVisibility"
/// }
/// },
/// "additionalProperties": false
/// },
/// "community": {
/// "description": "The community's DID.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "description": {
/// "type": "string",
/// "maxLength": 8192
/// },
/// "electionId": {
/// "$ref": "#/definitions/ElectionId"
/// },
/// "questions": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/Question"
/// },
/// "maxItems": 128,
/// "minItems": 1
/// },
/// "registrationOpensAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "resultsBeforeClose": {
/// "description": "Open elections only: whether running totals may be read while voting is open (VTI-VOT-061).",
/// "type": "boolean"
/// },
/// "revote": {
/// "$ref": "#/definitions/Revote"
/// },
/// "roll": {
/// "$ref": "#/definitions/RollRule"
/// },
/// "secrecy": {
/// "$ref": "#/definitions/SecrecyLevel"
/// },
/// "textReleaseThreshold": {
/// "description": "Counted ballots required before any text answer is disclosed (VTI-VOT-065).",
/// "type": "integer",
/// "minimum": 10.0
/// },
/// "title": {
/// "type": "string",
/// "maxLength": 512
/// },
/// "trustees": {
/// "$ref": "#/definitions/Trustees"
/// },
/// "votingClosesAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "votingOpensAt": {
/// "type": "string",
/// "format": "date-time"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Manifest {
#[serde(rename = "allowEarlyClose")]
pub allow_early_close: bool,
///The DID of the voting service that holds the board.
#[serde(rename = "ballotBox")]
pub ballot_box: ManifestBallotBox,
///Whether the community treats the result as deciding something; creating a binding election takes another administrator's consent (VTI-VOT-081).
pub binding: bool,
pub board: ManifestBoard,
///The community's DID.
pub community: ManifestCommunity,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub description: ::std::option::Option<ManifestDescription>,
#[serde(rename = "electionId")]
pub election_id: ElectionId,
pub questions: ::std::vec::Vec<Question>,
#[serde(rename = "registrationOpensAt")]
pub registration_opens_at: ::chrono::DateTime<::chrono::offset::Utc>,
///Open elections only: whether running totals may be read while voting is open (VTI-VOT-061).
#[serde(rename = "resultsBeforeClose")]
pub results_before_close: bool,
pub revote: Revote,
pub roll: RollRule,
pub secrecy: SecrecyLevel,
///Counted ballots required before any text answer is disclosed (VTI-VOT-065).
#[serde(rename = "textReleaseThreshold")]
pub text_release_threshold: i64,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub title: ::std::option::Option<ManifestTitle>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub trustees: ::std::option::Option<Trustees>,
#[serde(rename = "votingClosesAt")]
pub voting_closes_at: ::chrono::DateTime<::chrono::offset::Utc>,
#[serde(rename = "votingOpensAt")]
pub voting_opens_at: ::chrono::DateTime<::chrono::offset::Utc>,
}
impl Manifest {
pub fn builder() -> builder::Manifest {
Default::default()
}
}
///The DID of the voting service that holds the board.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The DID of the voting service that holds the board.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ManifestBallotBox(::std::string::String);
impl ::std::ops::Deref for ManifestBallotBox {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ManifestBallotBox> for ::std::string::String {
fn from(value: ManifestBallotBox) -> Self {
value.0
}
}
impl ::std::str::FromStr for ManifestBallotBox {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ManifestBallotBox {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ManifestBallotBox {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ManifestBallotBox {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ManifestBallotBox {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`ManifestBoard`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "auditors",
/// "visibility"
/// ],
/// "properties": {
/// "auditors": {
/// "type": "array",
/// "items": {
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "uniqueItems": true
/// },
/// "visibility": {
/// "$ref": "#/definitions/BoardVisibility"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ManifestBoard {
pub auditors: Vec<ManifestBoardAuditorsItem>,
pub visibility: BoardVisibility,
}
impl ManifestBoard {
pub fn builder() -> builder::ManifestBoard {
Default::default()
}
}
///`ManifestBoardAuditorsItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ManifestBoardAuditorsItem(::std::string::String);
impl ::std::ops::Deref for ManifestBoardAuditorsItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ManifestBoardAuditorsItem> for ::std::string::String {
fn from(value: ManifestBoardAuditorsItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for ManifestBoardAuditorsItem {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ManifestBoardAuditorsItem {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ManifestBoardAuditorsItem {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ManifestBoardAuditorsItem {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ManifestBoardAuditorsItem {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///The community's DID.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The community's DID.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ManifestCommunity(::std::string::String);
impl ::std::ops::Deref for ManifestCommunity {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ManifestCommunity> for ::std::string::String {
fn from(value: ManifestCommunity) -> Self {
value.0
}
}
impl ::std::str::FromStr for ManifestCommunity {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ManifestCommunity {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ManifestCommunity {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ManifestCommunity {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ManifestCommunity {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`ManifestDescription`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 8192
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ManifestDescription(::std::string::String);
impl ::std::ops::Deref for ManifestDescription {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ManifestDescription> for ::std::string::String {
fn from(value: ManifestDescription) -> Self {
value.0
}
}
impl ::std::str::FromStr for ManifestDescription {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 8192usize {
return Err("longer than 8192 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ManifestDescription {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ManifestDescription {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ManifestDescription {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ManifestDescription {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`ManifestTitle`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 512
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ManifestTitle(::std::string::String);
impl ::std::ops::Deref for ManifestTitle {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ManifestTitle> for ::std::string::String {
fn from(value: ManifestTitle) -> Self {
value.0
}
}
impl ::std::str::FromStr for ManifestTitle {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 512usize {
return Err("longer than 512 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ManifestTitle {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ManifestTitle {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ManifestTitle {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ManifestTitle {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///The dealer's VTA reveals the share it dealt to a trustee that complained, and returns the voting/trustees/justify request signed as the dealer.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/vta/pcs/trustee/justify/0.3",
/// "title": "Payload",
/// "description": "The dealer's VTA reveals the share it dealt to a trustee that complained, and returns the voting/trustees/justify request signed as the dealer.",
/// "type": "object",
/// "required": [
/// "ceremony",
/// "community",
/// "contextId",
/// "electionId",
/// "manifest",
/// "recipient",
/// "trustee"
/// ],
/// "properties": {
/// "ceremony": {
/// "description": "The ceremony as the board holds it: voting/trustees/status's `steps`, passed on unchanged. The VTA verifies every step as its trustee's before taking it.",
/// "$ref": "#/definitions/TrusteeCeremony"
/// },
/// "community": {
/// "description": "The community's DID.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "contextId": {
/// "description": "The VTA context the trustee's keys live in.",
/// "type": "string",
/// "maxLength": 256,
/// "minLength": 1
/// },
/// "electionId": {
/// "$ref": "#/definitions/ElectionId"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "manifest": {
/// "$ref": "#/definitions/Manifest"
/// },
/// "recipient": {
/// "$ref": "#/definitions/TrusteeIndex"
/// },
/// "trustee": {
/// "description": "The trustee's DID: a persona this VTA holds, named in the manifest's `trustees.dids`.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///The ceremony as the board holds it: voting/trustees/status's `steps`, passed on unchanged. The VTA verifies every step as its trustee's before taking it.
pub ceremony: TrusteeCeremony,
///The community's DID.
pub community: PayloadCommunity,
///The VTA context the trustee's keys live in.
#[serde(rename = "contextId")]
pub context_id: PayloadContextId,
#[serde(rename = "electionId")]
pub election_id: ElectionId,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
pub manifest: Manifest,
pub recipient: TrusteeIndex,
///The trustee's DID: a persona this VTA holds, named in the manifest's `trustees.dids`.
pub trustee: PayloadTrustee,
}
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 VTA context the trustee's keys live in.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The VTA context the trustee's keys live in.",
/// "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())
})
}
}
///The trustee's DID: a persona this VTA holds, named in the manifest's `trustees.dids`.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The trustee's DID: a persona this VTA holds, named in the manifest's `trustees.dids`.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadTrustee(::std::string::String);
impl ::std::ops::Deref for PayloadTrustee {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadTrustee> for ::std::string::String {
fn from(value: PayloadTrustee) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadTrustee {
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 PayloadTrustee {
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 PayloadTrustee {
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 PayloadTrustee {
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 PayloadTrustee {
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": [
/// "document"
/// ],
/// "properties": {
/// "document": {
/// "title": "JustifyDocument",
/// "description": "The voting/trustees/justify request, signed as the trustee.",
/// "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/trustees/justify/0.1"
/// }
/// }
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
pub document: JustifyDocument,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///What a later, different ballot under one ticket does: `replace` the earlier one, or be refused (`refuse`) (VTI-VOT-041).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Revote",
/// "description": "What a later, different ballot under one ticket does: `replace` the earlier one, or be refused (`refuse`) (VTI-VOT-041).",
/// "type": "string",
/// "enum": [
/// "replace",
/// "refuse"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum Revote {
#[serde(rename = "replace")]
Replace,
#[serde(rename = "refuse")]
Refuse,
}
impl ::std::fmt::Display for Revote {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Replace => f.write_str("replace"),
Self::Refuse => f.write_str("refuse"),
}
}
}
impl ::std::str::FromStr for Revote {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"replace" => Ok(Self::Replace),
"refuse" => Ok(Self::Refuse),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for Revote {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for Revote {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for Revote {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Who may be issued a ticket (VTI-VOT-021): the community's active members, its active members and the parties `listed` names, or only the parties `listed` names.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "RollRule",
/// "description": "Who may be issued a ticket (VTI-VOT-021): the community's active members, its active members and the parties `listed` names, or only the parties `listed` names.",
/// "type": "object",
/// "required": [
/// "rule"
/// ],
/// "properties": {
/// "listed": {
/// "type": "array",
/// "items": {
/// "description": "A DID enfranchised by name.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "uniqueItems": true
/// },
/// "rule": {
/// "type": "string",
/// "enum": [
/// "members",
/// "membersAndListed",
/// "listed"
/// ]
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct RollRule {
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub listed: ::std::option::Option<Vec<RollRuleListedItem>>,
pub rule: RollRuleRule,
}
impl RollRule {
pub fn builder() -> builder::RollRule {
Default::default()
}
}
///A DID enfranchised by name.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "A DID enfranchised by name.",
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct RollRuleListedItem(::std::string::String);
impl ::std::ops::Deref for RollRuleListedItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<RollRuleListedItem> for ::std::string::String {
fn from(value: RollRuleListedItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for RollRuleListedItem {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for RollRuleListedItem {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for RollRuleListedItem {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for RollRuleListedItem {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for RollRuleListedItem {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///`RollRuleRule`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "enum": [
/// "members",
/// "membersAndListed",
/// "listed"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum RollRuleRule {
#[serde(rename = "members")]
Members,
#[serde(rename = "membersAndListed")]
MembersAndListed,
#[serde(rename = "listed")]
Listed,
}
impl ::std::fmt::Display for RollRuleRule {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Members => f.write_str("members"),
Self::MembersAndListed => f.write_str("membersAndListed"),
Self::Listed => f.write_str("listed"),
}
}
}
impl ::std::str::FromStr for RollRuleRule {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"members" => Ok(Self::Members),
"membersAndListed" => Ok(Self::MembersAndListed),
"listed" => Ok(Self::Listed),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for RollRuleRule {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for RollRuleRule {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for RollRuleRule {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///`open`: ballots are recorded on the board as cast. `sealed`: ballots are encrypted to a jointly generated election key and decrypted after voting closes. `talliedEncrypted`: ballots are encrypted and only the totals are ever decrypted (VTI-VOT-060). The encrypted levels are cast with `voting/ballot/cast-encrypted/0.1`, under an election key the trustees generate with `voting/trustees/*` (CONVENTIONS §9).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "SecrecyLevel",
/// "description": "`open`: ballots are recorded on the board as cast. `sealed`: ballots are encrypted to a jointly generated election key and decrypted after voting closes. `talliedEncrypted`: ballots are encrypted and only the totals are ever decrypted (VTI-VOT-060). The encrypted levels are cast with `voting/ballot/cast-encrypted/0.1`, under an election key the trustees generate with `voting/trustees/*` (CONVENTIONS §9).",
/// "type": "string",
/// "enum": [
/// "open",
/// "sealed",
/// "talliedEncrypted"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum SecrecyLevel {
#[serde(rename = "open")]
Open,
#[serde(rename = "sealed")]
Sealed,
#[serde(rename = "talliedEncrypted")]
TalliedEncrypted,
}
impl ::std::fmt::Display for SecrecyLevel {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Open => f.write_str("open"),
Self::Sealed => f.write_str("sealed"),
Self::TalliedEncrypted => f.write_str("talliedEncrypted"),
}
}
}
impl ::std::str::FromStr for SecrecyLevel {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"open" => Ok(Self::Open),
"sealed" => Ok(Self::Sealed),
"talliedEncrypted" => Ok(Self::TalliedEncrypted),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for SecrecyLevel {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for SecrecyLevel {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for SecrecyLevel {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///A whole Trust Task request document — `id`, `type`, `issuer`, `payload` and every other member, `proof` included — exactly as the ballot box received it, never re-serialised: its proof is taken over its members, and a re-serialised copy does not reliably reproduce them. Typed as an open object so every member survives; CONVENTIONS §9.6 gives the checks that make it a trustee's step.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "SignedRequest",
/// "description": "A whole Trust Task request document — `id`, `type`, `issuer`, `payload` and every other member, `proof` included — exactly as the ballot box received it, never re-serialised: its proof is taken over its members, and a re-serialised copy does not reliably reproduce them. Typed as an open object so every member survives; CONVENTIONS §9.6 gives the checks that make it a trustee's step.",
/// "type": "object",
/// "minProperties": 1
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct SignedRequest(pub ::serde_json::Map<::std::string::String, ::serde_json::Value>);
impl ::std::ops::Deref for SignedRequest {
type Target = ::serde_json::Map<::std::string::String, ::serde_json::Value>;
fn deref(&self) -> &::serde_json::Map<::std::string::String, ::serde_json::Value> {
&self.0
}
}
impl ::std::convert::From<SignedRequest>
for ::serde_json::Map<::std::string::String, ::serde_json::Value>
{
fn from(value: SignedRequest) -> Self {
value.0
}
}
impl ::std::convert::From<::serde_json::Map<::std::string::String, ::serde_json::Value>>
for SignedRequest
{
fn from(value: ::serde_json::Map<::std::string::String, ::serde_json::Value>) -> Self {
Self(value)
}
}
///The trustees' ceremony as the board holds it: the `request` of every `trusteeStep` entry, in board order, each exactly as the ballot box received it (CONVENTIONS §9.6). Whoever acts on it verifies each step as its trustee's before taking it; nothing in it is believed for having been passed along.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "TrusteeCeremony",
/// "description": "The trustees' ceremony as the board holds it: the `request` of every `trusteeStep` entry, in board order, each exactly as the ballot box received it (CONVENTIONS §9.6). Whoever acts on it verifies each step as its trustee's before taking it; nothing in it is believed for having been passed along.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/SignedRequest"
/// },
/// "maxItems": 4224,
/// "minItems": 1
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct TrusteeCeremony(pub ::std::vec::Vec<SignedRequest>);
impl ::std::ops::Deref for TrusteeCeremony {
type Target = ::std::vec::Vec<SignedRequest>;
fn deref(&self) -> &::std::vec::Vec<SignedRequest> {
&self.0
}
}
impl ::std::convert::From<TrusteeCeremony> for ::std::vec::Vec<SignedRequest> {
fn from(value: TrusteeCeremony) -> Self {
value.0
}
}
impl ::std::convert::From<::std::vec::Vec<SignedRequest>> for TrusteeCeremony {
fn from(value: ::std::vec::Vec<SignedRequest>) -> Self {
Self(value)
}
}
///A trustee's index: its position in the manifest's `trustees.dids`, counting from 1.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "TrusteeIndex",
/// "description": "A trustee's index: its position in the manifest's `trustees.dids`, counting from 1.",
/// "type": "integer",
/// "maximum": 64.0,
/// "minimum": 1.0
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct TrusteeIndex(pub ::std::num::NonZeroU64);
impl ::std::ops::Deref for TrusteeIndex {
type Target = ::std::num::NonZeroU64;
fn deref(&self) -> &::std::num::NonZeroU64 {
&self.0
}
}
impl ::std::convert::From<TrusteeIndex> for ::std::num::NonZeroU64 {
fn from(value: TrusteeIndex) -> Self {
value.0
}
}
impl ::std::convert::From<::std::num::NonZeroU64> for TrusteeIndex {
fn from(value: ::std::num::NonZeroU64) -> Self {
Self(value)
}
}
impl ::std::str::FromStr for TrusteeIndex {
type Err = <::std::num::NonZeroU64 as ::std::str::FromStr>::Err;
fn from_str(value: &str) -> ::std::result::Result<Self, Self::Err> {
Ok(Self(value.parse()?))
}
}
impl ::std::convert::TryFrom<&str> for TrusteeIndex {
type Error = <::std::num::NonZeroU64 as ::std::str::FromStr>::Err;
fn try_from(value: &str) -> ::std::result::Result<Self, Self::Error> {
value.parse()
}
}
impl ::std::convert::TryFrom<String> for TrusteeIndex {
type Error = <::std::num::NonZeroU64 as ::std::str::FromStr>::Err;
fn try_from(value: String) -> ::std::result::Result<Self, Self::Error> {
value.parse()
}
}
impl ::std::fmt::Display for TrusteeIndex {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
self.0.fmt(f)
}
}
///The trustees of a sealed or tallied-encrypted election and the number of them decryption needs (VTI-VOT-062). Neither the community nor the ballot box may be one.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Trustees",
/// "description": "The trustees of a sealed or tallied-encrypted election and the number of them decryption needs (VTI-VOT-062). Neither the community nor the ballot box may be one.",
/// "type": "object",
/// "required": [
/// "dids",
/// "threshold"
/// ],
/// "properties": {
/// "dids": {
/// "type": "array",
/// "items": {
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
/// },
/// "minItems": 2,
/// "uniqueItems": true
/// },
/// "threshold": {
/// "type": "integer",
/// "minimum": 2.0
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Trustees {
pub dids: Vec<TrusteesDidsItem>,
pub threshold: i64,
}
impl Trustees {
pub fn builder() -> builder::Trustees {
Default::default()
}
}
///`TrusteesDidsItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 2048,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct TrusteesDidsItem(::std::string::String);
impl ::std::ops::Deref for TrusteesDidsItem {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<TrusteesDidsItem> for ::std::string::String {
fn from(value: TrusteesDidsItem) -> Self {
value.0
}
}
impl ::std::str::FromStr for TrusteesDidsItem {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 2048usize {
return Err("longer than 2048 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for TrusteesDidsItem {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for TrusteesDidsItem {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for TrusteesDidsItem {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for TrusteesDidsItem {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct JustifyDocument {
expires_at: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
id: ::std::result::Result<super::JustifyDocumentId, ::std::string::String>,
issued_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
issuer: ::std::result::Result<super::JustifyDocumentIssuer, ::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::JustifyDocumentRecipient, ::std::string::String>,
type_: ::std::result::Result<::serde_json::Value, ::std::string::String>,
}
impl ::std::default::Default for JustifyDocument {
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 JustifyDocument {
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::JustifyDocumentId>,
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::JustifyDocumentIssuer>,
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::JustifyDocumentRecipient>,
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<JustifyDocument> for super::JustifyDocument {
type Error = super::error::ConversionError;
fn try_from(
value: JustifyDocument,
) -> ::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::JustifyDocument> for JustifyDocument {
fn from(value: super::JustifyDocument) -> 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 Manifest {
allow_early_close: ::std::result::Result<bool, ::std::string::String>,
ballot_box: ::std::result::Result<super::ManifestBallotBox, ::std::string::String>,
binding: ::std::result::Result<bool, ::std::string::String>,
board: ::std::result::Result<super::ManifestBoard, ::std::string::String>,
community: ::std::result::Result<super::ManifestCommunity, ::std::string::String>,
description: ::std::result::Result<
::std::option::Option<super::ManifestDescription>,
::std::string::String,
>,
election_id: ::std::result::Result<super::ElectionId, ::std::string::String>,
questions: ::std::result::Result<::std::vec::Vec<super::Question>, ::std::string::String>,
registration_opens_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
results_before_close: ::std::result::Result<bool, ::std::string::String>,
revote: ::std::result::Result<super::Revote, ::std::string::String>,
roll: ::std::result::Result<super::RollRule, ::std::string::String>,
secrecy: ::std::result::Result<super::SecrecyLevel, ::std::string::String>,
text_release_threshold: ::std::result::Result<i64, ::std::string::String>,
title: ::std::result::Result<
::std::option::Option<super::ManifestTitle>,
::std::string::String,
>,
trustees:
::std::result::Result<::std::option::Option<super::Trustees>, ::std::string::String>,
voting_closes_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
voting_opens_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
}
impl ::std::default::Default for Manifest {
fn default() -> Self {
Self {
allow_early_close: Err("no value supplied for allow_early_close".to_string()),
ballot_box: Err("no value supplied for ballot_box".to_string()),
binding: Err("no value supplied for binding".to_string()),
board: Err("no value supplied for board".to_string()),
community: Err("no value supplied for community".to_string()),
description: Ok(Default::default()),
election_id: Err("no value supplied for election_id".to_string()),
questions: Err("no value supplied for questions".to_string()),
registration_opens_at: Err(
"no value supplied for registration_opens_at".to_string()
),
results_before_close: Err("no value supplied for results_before_close".to_string()),
revote: Err("no value supplied for revote".to_string()),
roll: Err("no value supplied for roll".to_string()),
secrecy: Err("no value supplied for secrecy".to_string()),
text_release_threshold: Err(
"no value supplied for text_release_threshold".to_string()
),
title: Ok(Default::default()),
trustees: Ok(Default::default()),
voting_closes_at: Err("no value supplied for voting_closes_at".to_string()),
voting_opens_at: Err("no value supplied for voting_opens_at".to_string()),
}
}
}
impl Manifest {
pub fn allow_early_close<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.allow_early_close = value
.try_into()
.map_err(|e| format!("error converting supplied value for allow_early_close: {e}"));
self
}
pub fn ballot_box<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ManifestBallotBox>,
T::Error: ::std::fmt::Display,
{
self.ballot_box = value
.try_into()
.map_err(|e| format!("error converting supplied value for ballot_box: {e}"));
self
}
pub fn binding<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.binding = value
.try_into()
.map_err(|e| format!("error converting supplied value for binding: {e}"));
self
}
pub fn board<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ManifestBoard>,
T::Error: ::std::fmt::Display,
{
self.board = value
.try_into()
.map_err(|e| format!("error converting supplied value for board: {e}"));
self
}
pub fn community<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ManifestCommunity>,
T::Error: ::std::fmt::Display,
{
self.community = value
.try_into()
.map_err(|e| format!("error converting supplied value for community: {e}"));
self
}
pub fn description<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ManifestDescription>>,
T::Error: ::std::fmt::Display,
{
self.description = value
.try_into()
.map_err(|e| format!("error converting supplied value for description: {e}"));
self
}
pub fn election_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElectionId>,
T::Error: ::std::fmt::Display,
{
self.election_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for election_id: {e}"));
self
}
pub fn questions<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::Question>>,
T::Error: ::std::fmt::Display,
{
self.questions = value
.try_into()
.map_err(|e| format!("error converting supplied value for questions: {e}"));
self
}
pub fn registration_opens_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.registration_opens_at = value.try_into().map_err(|e| {
format!("error converting supplied value for registration_opens_at: {e}")
});
self
}
pub fn results_before_close<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.results_before_close = value.try_into().map_err(|e| {
format!("error converting supplied value for results_before_close: {e}")
});
self
}
pub fn revote<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Revote>,
T::Error: ::std::fmt::Display,
{
self.revote = value
.try_into()
.map_err(|e| format!("error converting supplied value for revote: {e}"));
self
}
pub fn roll<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::RollRule>,
T::Error: ::std::fmt::Display,
{
self.roll = value
.try_into()
.map_err(|e| format!("error converting supplied value for roll: {e}"));
self
}
pub fn secrecy<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::SecrecyLevel>,
T::Error: ::std::fmt::Display,
{
self.secrecy = value
.try_into()
.map_err(|e| format!("error converting supplied value for secrecy: {e}"));
self
}
pub fn text_release_threshold<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<i64>,
T::Error: ::std::fmt::Display,
{
self.text_release_threshold = value.try_into().map_err(|e| {
format!("error converting supplied value for text_release_threshold: {e}")
});
self
}
pub fn title<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ManifestTitle>>,
T::Error: ::std::fmt::Display,
{
self.title = value
.try_into()
.map_err(|e| format!("error converting supplied value for title: {e}"));
self
}
pub fn trustees<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Trustees>>,
T::Error: ::std::fmt::Display,
{
self.trustees = value
.try_into()
.map_err(|e| format!("error converting supplied value for trustees: {e}"));
self
}
pub fn voting_closes_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.voting_closes_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for voting_closes_at: {e}"));
self
}
pub fn voting_opens_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.voting_opens_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for voting_opens_at: {e}"));
self
}
}
impl ::std::convert::TryFrom<Manifest> for super::Manifest {
type Error = super::error::ConversionError;
fn try_from(value: Manifest) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
allow_early_close: value.allow_early_close?,
ballot_box: value.ballot_box?,
binding: value.binding?,
board: value.board?,
community: value.community?,
description: value.description?,
election_id: value.election_id?,
questions: value.questions?,
registration_opens_at: value.registration_opens_at?,
results_before_close: value.results_before_close?,
revote: value.revote?,
roll: value.roll?,
secrecy: value.secrecy?,
text_release_threshold: value.text_release_threshold?,
title: value.title?,
trustees: value.trustees?,
voting_closes_at: value.voting_closes_at?,
voting_opens_at: value.voting_opens_at?,
})
}
}
impl ::std::convert::From<super::Manifest> for Manifest {
fn from(value: super::Manifest) -> Self {
Self {
allow_early_close: Ok(value.allow_early_close),
ballot_box: Ok(value.ballot_box),
binding: Ok(value.binding),
board: Ok(value.board),
community: Ok(value.community),
description: Ok(value.description),
election_id: Ok(value.election_id),
questions: Ok(value.questions),
registration_opens_at: Ok(value.registration_opens_at),
results_before_close: Ok(value.results_before_close),
revote: Ok(value.revote),
roll: Ok(value.roll),
secrecy: Ok(value.secrecy),
text_release_threshold: Ok(value.text_release_threshold),
title: Ok(value.title),
trustees: Ok(value.trustees),
voting_closes_at: Ok(value.voting_closes_at),
voting_opens_at: Ok(value.voting_opens_at),
}
}
}
#[derive(Clone, Debug)]
pub struct ManifestBoard {
auditors:
::std::result::Result<Vec<super::ManifestBoardAuditorsItem>, ::std::string::String>,
visibility: ::std::result::Result<super::BoardVisibility, ::std::string::String>,
}
impl ::std::default::Default for ManifestBoard {
fn default() -> Self {
Self {
auditors: Err("no value supplied for auditors".to_string()),
visibility: Err("no value supplied for visibility".to_string()),
}
}
}
impl ManifestBoard {
pub fn auditors<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<Vec<super::ManifestBoardAuditorsItem>>,
T::Error: ::std::fmt::Display,
{
self.auditors = value
.try_into()
.map_err(|e| format!("error converting supplied value for auditors: {e}"));
self
}
pub fn visibility<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::BoardVisibility>,
T::Error: ::std::fmt::Display,
{
self.visibility = value
.try_into()
.map_err(|e| format!("error converting supplied value for visibility: {e}"));
self
}
}
impl ::std::convert::TryFrom<ManifestBoard> for super::ManifestBoard {
type Error = super::error::ConversionError;
fn try_from(
value: ManifestBoard,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
auditors: value.auditors?,
visibility: value.visibility?,
})
}
}
impl ::std::convert::From<super::ManifestBoard> for ManifestBoard {
fn from(value: super::ManifestBoard) -> Self {
Self {
auditors: Ok(value.auditors),
visibility: Ok(value.visibility),
}
}
}
#[derive(Clone, Debug)]
pub struct Payload {
ceremony: ::std::result::Result<super::TrusteeCeremony, ::std::string::String>,
community: ::std::result::Result<super::PayloadCommunity, ::std::string::String>,
context_id: ::std::result::Result<super::PayloadContextId, ::std::string::String>,
election_id: ::std::result::Result<super::ElectionId, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
manifest: ::std::result::Result<super::Manifest, ::std::string::String>,
recipient: ::std::result::Result<super::TrusteeIndex, ::std::string::String>,
trustee: ::std::result::Result<super::PayloadTrustee, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
ceremony: Err("no value supplied for ceremony".to_string()),
community: Err("no value supplied for community".to_string()),
context_id: Err("no value supplied for context_id".to_string()),
election_id: Err("no value supplied for election_id".to_string()),
ext: Ok(Default::default()),
manifest: Err("no value supplied for manifest".to_string()),
recipient: Err("no value supplied for recipient".to_string()),
trustee: Err("no value supplied for trustee".to_string()),
}
}
}
impl Payload {
pub fn ceremony<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::TrusteeCeremony>,
T::Error: ::std::fmt::Display,
{
self.ceremony = value
.try_into()
.map_err(|e| format!("error converting supplied value for ceremony: {e}"));
self
}
pub fn 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_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElectionId>,
T::Error: ::std::fmt::Display,
{
self.election_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for election_id: {e}"));
self
}
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
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 recipient<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::TrusteeIndex>,
T::Error: ::std::fmt::Display,
{
self.recipient = value
.try_into()
.map_err(|e| format!("error converting supplied value for recipient: {e}"));
self
}
pub fn trustee<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadTrustee>,
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<Payload> for super::Payload {
type Error = super::error::ConversionError;
fn try_from(value: Payload) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
ceremony: value.ceremony?,
community: value.community?,
context_id: value.context_id?,
election_id: value.election_id?,
ext: value.ext?,
manifest: value.manifest?,
recipient: value.recipient?,
trustee: value.trustee?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
ceremony: Ok(value.ceremony),
community: Ok(value.community),
context_id: Ok(value.context_id),
election_id: Ok(value.election_id),
ext: Ok(value.ext),
manifest: Ok(value.manifest),
recipient: Ok(value.recipient),
trustee: Ok(value.trustee),
}
}
}
#[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 {
document: ::std::result::Result<super::JustifyDocument, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
document: Err("no value supplied for document".to_string()),
ext: Ok(Default::default()),
}
}
}
impl Response {
pub fn document<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::JustifyDocument>,
T::Error: ::std::fmt::Display,
{
self.document = value
.try_into()
.map_err(|e| format!("error converting supplied value for 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
}
}
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 {
document: value.document?,
ext: value.ext?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
document: Ok(value.document),
ext: Ok(value.ext),
}
}
}
#[derive(Clone, Debug)]
pub struct RollRule {
listed: ::std::result::Result<
::std::option::Option<Vec<super::RollRuleListedItem>>,
::std::string::String,
>,
rule: ::std::result::Result<super::RollRuleRule, ::std::string::String>,
}
impl ::std::default::Default for RollRule {
fn default() -> Self {
Self {
listed: Ok(Default::default()),
rule: Err("no value supplied for rule".to_string()),
}
}
}
impl RollRule {
pub fn listed<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<Vec<super::RollRuleListedItem>>>,
T::Error: ::std::fmt::Display,
{
self.listed = value
.try_into()
.map_err(|e| format!("error converting supplied value for listed: {e}"));
self
}
pub fn rule<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::RollRuleRule>,
T::Error: ::std::fmt::Display,
{
self.rule = value
.try_into()
.map_err(|e| format!("error converting supplied value for rule: {e}"));
self
}
}
impl ::std::convert::TryFrom<RollRule> for super::RollRule {
type Error = super::error::ConversionError;
fn try_from(value: RollRule) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
listed: value.listed?,
rule: value.rule?,
})
}
}
impl ::std::convert::From<super::RollRule> for RollRule {
fn from(value: super::RollRule) -> Self {
Self {
listed: Ok(value.listed),
rule: Ok(value.rule),
}
}
}
#[derive(Clone, Debug)]
pub struct Trustees {
dids: ::std::result::Result<Vec<super::TrusteesDidsItem>, ::std::string::String>,
threshold: ::std::result::Result<i64, ::std::string::String>,
}
impl ::std::default::Default for Trustees {
fn default() -> Self {
Self {
dids: Err("no value supplied for dids".to_string()),
threshold: Err("no value supplied for threshold".to_string()),
}
}
}
impl Trustees {
pub fn dids<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<Vec<super::TrusteesDidsItem>>,
T::Error: ::std::fmt::Display,
{
self.dids = value
.try_into()
.map_err(|e| format!("error converting supplied value for dids: {e}"));
self
}
pub fn threshold<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<i64>,
T::Error: ::std::fmt::Display,
{
self.threshold = value
.try_into()
.map_err(|e| format!("error converting supplied value for threshold: {e}"));
self
}
}
impl ::std::convert::TryFrom<Trustees> for super::Trustees {
type Error = super::error::ConversionError;
fn try_from(value: Trustees) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
dids: value.dids?,
threshold: value.threshold?,
})
}
}
impl ::std::convert::From<super::Trustees> for Trustees {
fn from(value: super::Trustees) -> Self {
Self {
dids: Ok(value.dids),
threshold: Ok(value.threshold),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vta/pcs/trustee/justify/0.3";
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 \"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 \"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 \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"Key\": {\n \"description\": \"A question or option key, unique within its manifest or question.\",\n \"pattern\": \"^[A-Za-z0-9._-]{1,64}$\",\n \"title\": \"Key\",\n \"type\": \"string\"\n },\n \"Manifest\": {\n \"additionalProperties\": false,\n \"description\": \"What an election asks and how it is decided (VTI-VOT-010). Its digest (`manifestDigest`) is the SHA-256 multihash of its RFC 8785 (JCS) canonicalization, and every cast is bound to it (VTI-VOT-011).\",\n \"properties\": {\n \"allowEarlyClose\": {\n \"type\": \"boolean\"\n },\n \"ballotBox\": {\n \"description\": \"The DID of the voting service that holds the board.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"binding\": {\n \"description\": \"Whether the community treats the result as deciding something; creating a binding election takes another administrator's consent (VTI-VOT-081).\",\n \"type\": \"boolean\"\n },\n \"board\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"auditors\": {\n \"items\": {\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"visibility\": {\n \"$ref\": \"#/$defs/BoardVisibility\"\n }\n },\n \"required\": [\n \"visibility\",\n \"auditors\"\n ],\n \"type\": \"object\"\n },\n \"community\": {\n \"description\": \"The community's DID.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"description\": {\n \"maxLength\": 8192,\n \"type\": \"string\"\n },\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"questions\": {\n \"items\": {\n \"$ref\": \"#/$defs/Question\"\n },\n \"maxItems\": 128,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"registrationOpensAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"resultsBeforeClose\": {\n \"description\": \"Open elections only: whether running totals may be read while voting is open (VTI-VOT-061).\",\n \"type\": \"boolean\"\n },\n \"revote\": {\n \"$ref\": \"#/$defs/Revote\"\n },\n \"roll\": {\n \"$ref\": \"#/$defs/RollRule\"\n },\n \"secrecy\": {\n \"$ref\": \"#/$defs/SecrecyLevel\"\n },\n \"textReleaseThreshold\": {\n \"description\": \"Counted ballots required before any text answer is disclosed (VTI-VOT-065).\",\n \"minimum\": 10,\n \"type\": \"integer\"\n },\n \"title\": {\n \"maxLength\": 512,\n \"type\": \"string\"\n },\n \"trustees\": {\n \"$ref\": \"#/$defs/Trustees\"\n },\n \"votingClosesAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"votingOpensAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"electionId\",\n \"community\",\n \"questions\",\n \"secrecy\",\n \"roll\",\n \"registrationOpensAt\",\n \"votingOpensAt\",\n \"votingClosesAt\",\n \"revote\",\n \"board\",\n \"ballotBox\",\n \"binding\",\n \"allowEarlyClose\",\n \"resultsBeforeClose\",\n \"textReleaseThreshold\"\n ],\n \"title\": \"Manifest\",\n \"type\": \"object\"\n },\n \"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 \"document\": {\n \"description\": \"The voting/trustees/justify request, signed as the trustee.\",\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/trustees/justify/0.1\"\n }\n },\n \"required\": [\n \"id\",\n \"type\",\n \"issuer\",\n \"recipient\",\n \"issuedAt\",\n \"payload\",\n \"proof\"\n ],\n \"title\": \"JustifyDocument\",\n \"type\": \"object\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n }\n },\n \"required\": [\n \"document\"\n ],\n \"title\": \"VTA PCS — Trustee Justify — response payload\",\n \"type\": \"object\"\n },\n \"Revote\": {\n \"description\": \"What a later, different ballot under one ticket does: `replace` the earlier one, or be refused (`refuse`) (VTI-VOT-041).\",\n \"enum\": [\n \"replace\",\n \"refuse\"\n ],\n \"title\": \"Revote\",\n \"type\": \"string\"\n },\n \"RollRule\": {\n \"additionalProperties\": false,\n \"description\": \"Who may be issued a ticket (VTI-VOT-021): the community's active members, its active members and the parties `listed` names, or only the parties `listed` names.\",\n \"properties\": {\n \"listed\": {\n \"items\": {\n \"description\": \"A DID enfranchised by name.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"rule\": {\n \"enum\": [\n \"members\",\n \"membersAndListed\",\n \"listed\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"rule\"\n ],\n \"title\": \"RollRule\",\n \"type\": \"object\"\n },\n \"SecrecyLevel\": {\n \"description\": \"`open`: ballots are recorded on the board as cast. `sealed`: ballots are encrypted to a jointly generated election key and decrypted after voting closes. `talliedEncrypted`: ballots are encrypted and only the totals are ever decrypted (VTI-VOT-060). The encrypted levels are cast with `voting/ballot/cast-encrypted/0.1`, under an election key the trustees generate with `voting/trustees/*` (CONVENTIONS §9).\",\n \"enum\": [\n \"open\",\n \"sealed\",\n \"talliedEncrypted\"\n ],\n \"title\": \"SecrecyLevel\",\n \"type\": \"string\"\n },\n \"SignedRequest\": {\n \"description\": \"A whole Trust Task request document — `id`, `type`, `issuer`, `payload` and every other member, `proof` included — exactly as the ballot box received it, never re-serialised: its proof is taken over its members, and a re-serialised copy does not reliably reproduce them. Typed as an open object so every member survives; CONVENTIONS §9.6 gives the checks that make it a trustee's step.\",\n \"minProperties\": 1,\n \"title\": \"SignedRequest\",\n \"type\": \"object\"\n },\n \"TrusteeCeremony\": {\n \"description\": \"The trustees' ceremony as the board holds it: the `request` of every `trusteeStep` entry, in board order, each exactly as the ballot box received it (CONVENTIONS §9.6). Whoever acts on it verifies each step as its trustee's before taking it; nothing in it is believed for having been passed along.\",\n \"items\": {\n \"$ref\": \"#/$defs/SignedRequest\"\n },\n \"maxItems\": 4224,\n \"minItems\": 1,\n \"title\": \"TrusteeCeremony\",\n \"type\": \"array\"\n },\n \"TrusteeIndex\": {\n \"description\": \"A trustee's index: its position in the manifest's `trustees.dids`, counting from 1.\",\n \"maximum\": 64,\n \"minimum\": 1,\n \"title\": \"TrusteeIndex\",\n \"type\": \"integer\"\n },\n \"Trustees\": {\n \"additionalProperties\": false,\n \"description\": \"The trustees of a sealed or tallied-encrypted election and the number of them decryption needs (VTI-VOT-062). Neither the community nor the ballot box may be one.\",\n \"properties\": {\n \"dids\": {\n \"items\": {\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"minItems\": 2,\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"threshold\": {\n \"minimum\": 2,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"dids\",\n \"threshold\"\n ],\n \"title\": \"Trustees\",\n \"type\": \"object\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/vta/pcs/trustee/justify/0.3\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"The dealer's VTA reveals the share it dealt to a trustee that complained, and returns the voting/trustees/justify request signed as the dealer.\",\n \"properties\": {\n \"ceremony\": {\n \"$ref\": \"#/$defs/TrusteeCeremony\",\n \"description\": \"The ceremony as the board holds it: voting/trustees/status's `steps`, passed on unchanged. The VTA verifies every step as its trustee's before taking it.\"\n },\n \"community\": {\n \"description\": \"The community's DID.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"contextId\": {\n \"description\": \"The VTA context the trustee's keys live in.\",\n \"maxLength\": 256,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"manifest\": {\n \"$ref\": \"#/$defs/Manifest\"\n },\n \"recipient\": {\n \"$ref\": \"#/$defs/TrusteeIndex\"\n },\n \"trustee\": {\n \"description\": \"The trustee's DID: a persona this VTA holds, named in the manifest's `trustees.dids`.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"contextId\",\n \"community\",\n \"electionId\",\n \"trustee\",\n \"manifest\",\n \"ceremony\",\n \"recipient\"\n ],\n \"title\": \"VTA PCS — Trustee Justify — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/vta/pcs/trustee/justify/0.3#response";
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\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 \"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 \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"Key\": {\n \"description\": \"A question or option key, unique within its manifest or question.\",\n \"pattern\": \"^[A-Za-z0-9._-]{1,64}$\",\n \"title\": \"Key\",\n \"type\": \"string\"\n },\n \"Manifest\": {\n \"additionalProperties\": false,\n \"description\": \"What an election asks and how it is decided (VTI-VOT-010). Its digest (`manifestDigest`) is the SHA-256 multihash of its RFC 8785 (JCS) canonicalization, and every cast is bound to it (VTI-VOT-011).\",\n \"properties\": {\n \"allowEarlyClose\": {\n \"type\": \"boolean\"\n },\n \"ballotBox\": {\n \"description\": \"The DID of the voting service that holds the board.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"binding\": {\n \"description\": \"Whether the community treats the result as deciding something; creating a binding election takes another administrator's consent (VTI-VOT-081).\",\n \"type\": \"boolean\"\n },\n \"board\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"auditors\": {\n \"items\": {\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"visibility\": {\n \"$ref\": \"#/$defs/BoardVisibility\"\n }\n },\n \"required\": [\n \"visibility\",\n \"auditors\"\n ],\n \"type\": \"object\"\n },\n \"community\": {\n \"description\": \"The community's DID.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"description\": {\n \"maxLength\": 8192,\n \"type\": \"string\"\n },\n \"electionId\": {\n \"$ref\": \"#/$defs/ElectionId\"\n },\n \"questions\": {\n \"items\": {\n \"$ref\": \"#/$defs/Question\"\n },\n \"maxItems\": 128,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"registrationOpensAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"resultsBeforeClose\": {\n \"description\": \"Open elections only: whether running totals may be read while voting is open (VTI-VOT-061).\",\n \"type\": \"boolean\"\n },\n \"revote\": {\n \"$ref\": \"#/$defs/Revote\"\n },\n \"roll\": {\n \"$ref\": \"#/$defs/RollRule\"\n },\n \"secrecy\": {\n \"$ref\": \"#/$defs/SecrecyLevel\"\n },\n \"textReleaseThreshold\": {\n \"description\": \"Counted ballots required before any text answer is disclosed (VTI-VOT-065).\",\n \"minimum\": 10,\n \"type\": \"integer\"\n },\n \"title\": {\n \"maxLength\": 512,\n \"type\": \"string\"\n },\n \"trustees\": {\n \"$ref\": \"#/$defs/Trustees\"\n },\n \"votingClosesAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"votingOpensAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"electionId\",\n \"community\",\n \"questions\",\n \"secrecy\",\n \"roll\",\n \"registrationOpensAt\",\n \"votingOpensAt\",\n \"votingClosesAt\",\n \"revote\",\n \"board\",\n \"ballotBox\",\n \"binding\",\n \"allowEarlyClose\",\n \"resultsBeforeClose\",\n \"textReleaseThreshold\"\n ],\n \"title\": \"Manifest\",\n \"type\": \"object\"\n },\n \"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 \"document\": {\n \"description\": \"The voting/trustees/justify request, signed as the trustee.\",\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/trustees/justify/0.1\"\n }\n },\n \"required\": [\n \"id\",\n \"type\",\n \"issuer\",\n \"recipient\",\n \"issuedAt\",\n \"payload\",\n \"proof\"\n ],\n \"title\": \"JustifyDocument\",\n \"type\": \"object\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n }\n },\n \"required\": [\n \"document\"\n ],\n \"title\": \"VTA PCS — Trustee Justify — response payload\",\n \"type\": \"object\"\n },\n \"Revote\": {\n \"description\": \"What a later, different ballot under one ticket does: `replace` the earlier one, or be refused (`refuse`) (VTI-VOT-041).\",\n \"enum\": [\n \"replace\",\n \"refuse\"\n ],\n \"title\": \"Revote\",\n \"type\": \"string\"\n },\n \"RollRule\": {\n \"additionalProperties\": false,\n \"description\": \"Who may be issued a ticket (VTI-VOT-021): the community's active members, its active members and the parties `listed` names, or only the parties `listed` names.\",\n \"properties\": {\n \"listed\": {\n \"items\": {\n \"description\": \"A DID enfranchised by name.\",\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"rule\": {\n \"enum\": [\n \"members\",\n \"membersAndListed\",\n \"listed\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"rule\"\n ],\n \"title\": \"RollRule\",\n \"type\": \"object\"\n },\n \"SecrecyLevel\": {\n \"description\": \"`open`: ballots are recorded on the board as cast. `sealed`: ballots are encrypted to a jointly generated election key and decrypted after voting closes. `talliedEncrypted`: ballots are encrypted and only the totals are ever decrypted (VTI-VOT-060). The encrypted levels are cast with `voting/ballot/cast-encrypted/0.1`, under an election key the trustees generate with `voting/trustees/*` (CONVENTIONS §9).\",\n \"enum\": [\n \"open\",\n \"sealed\",\n \"talliedEncrypted\"\n ],\n \"title\": \"SecrecyLevel\",\n \"type\": \"string\"\n },\n \"SignedRequest\": {\n \"description\": \"A whole Trust Task request document — `id`, `type`, `issuer`, `payload` and every other member, `proof` included — exactly as the ballot box received it, never re-serialised: its proof is taken over its members, and a re-serialised copy does not reliably reproduce them. Typed as an open object so every member survives; CONVENTIONS §9.6 gives the checks that make it a trustee's step.\",\n \"minProperties\": 1,\n \"title\": \"SignedRequest\",\n \"type\": \"object\"\n },\n \"TrusteeCeremony\": {\n \"description\": \"The trustees' ceremony as the board holds it: the `request` of every `trusteeStep` entry, in board order, each exactly as the ballot box received it (CONVENTIONS §9.6). Whoever acts on it verifies each step as its trustee's before taking it; nothing in it is believed for having been passed along.\",\n \"items\": {\n \"$ref\": \"#/$defs/SignedRequest\"\n },\n \"maxItems\": 4224,\n \"minItems\": 1,\n \"title\": \"TrusteeCeremony\",\n \"type\": \"array\"\n },\n \"TrusteeIndex\": {\n \"description\": \"A trustee's index: its position in the manifest's `trustees.dids`, counting from 1.\",\n \"maximum\": 64,\n \"minimum\": 1,\n \"title\": \"TrusteeIndex\",\n \"type\": \"integer\"\n },\n \"Trustees\": {\n \"additionalProperties\": false,\n \"description\": \"The trustees of a sealed or tallied-encrypted election and the number of them decryption needs (VTI-VOT-062). Neither the community nor the ballot box may be one.\",\n \"properties\": {\n \"dids\": {\n \"items\": {\n \"maxLength\": 2048,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"minItems\": 2,\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"threshold\": {\n \"minimum\": 2,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"dids\",\n \"threshold\"\n ],\n \"title\": \"Trustees\",\n \"type\": \"object\"\n }\n },\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::TRUSTEE_NOT_HELD,
error_codes::NO_DEALING,
error_codes::CEREMONY_INVALID,
error_codes::NO_COMPLAINT,
];
/// 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/trustee/justify:trusteeNotHeld`
///
/// The VTA holds no `authentication` key of `trustee` that the caller may act as, or the manifest does not name `trustee` as a trustee.
///
/// Declared `retryable: false`.
pub const TRUSTEE_NOT_HELD: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/pcs/trustee/justify:trusteeNotHeld",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vta/pcs/trustee/justify:noDealing`
///
/// This VTA has not dealt for the trustee in this election.
///
/// Declared `retryable: false`.
pub const NO_DEALING: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/pcs/trustee/justify:noDealing",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vta/pcs/trustee/justify:ceremonyInvalid`
///
/// A step of `ceremony` is not its trustee's (CONVENTIONS §9.6).
///
/// Declared `retryable: false`.
pub const CEREMONY_INVALID: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/pcs/trustee/justify:ceremonyInvalid",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vta/pcs/trustee/justify:noComplaint`
///
/// No confirmation in `ceremony` from the trustee at `recipient` complains of this trustee.
///
/// Declared `retryable: false`.
pub const NO_COMPLAINT: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vta/pcs/trustee/justify:noComplaint",
retryable: false,
details_schema: ::core::option::Option::None,
};
}