//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vta/pcs/trustee/justify`. Version: `0.2`.
#![allow(deprecated)]
/// Why this specification version is deprecated (SPEC "Superseded and
/// Withdrawn Versions"), or `None` while it is current.
pub const DEPRECATION: Option<&str> = Some("superseded by vta/pcs/trustee/justify/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).
///
#[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.
///
#[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.
///
#[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`
///
#[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.
///
#[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`
///
#[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.
///
#[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.
///
#[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.
///
#[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).
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Manifest {
#[serde(rename = "allowEarlyClose")]
pub allow_early_close: bool,
///The DID of the voting service that holds the board.
#[serde(rename = "ballotBox")]
pub ballot_box: ManifestBallotBox,
///Whether the community treats the result as deciding something; creating a binding election takes another administrator's consent (VTI-VOT-081).
pub binding: bool,
pub board: ManifestBoard,
///The community's DID.
pub community: ManifestCommunity,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub description: ::std::option::Option<ManifestDescription>,
#[serde(rename = "electionId")]
pub election_id: ElectionId,
pub questions: ::std::vec::Vec<Question>,
#[serde(rename = "registrationOpens")]
pub registration_opens: ::chrono::DateTime<::chrono::offset::Utc>,
///Open elections only: whether running totals may be read while voting is open (VTI-VOT-061).
#[serde(rename = "resultsBeforeClose")]
pub results_before_close: bool,
pub revote: Revote,
pub roll: RollRule,
pub secrecy: SecrecyLevel,
///Counted ballots required before any text answer is disclosed (VTI-VOT-065).
#[serde(rename = "textReleaseThreshold")]
pub text_release_threshold: i64,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub title: ::std::option::Option<ManifestTitle>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub trustees: ::std::option::Option<Trustees>,
#[serde(rename = "votingCloses")]
pub voting_closes: ::chrono::DateTime<::chrono::offset::Utc>,
#[serde(rename = "votingOpens")]
pub voting_opens: ::chrono::DateTime<::chrono::offset::Utc>,
}
impl Manifest {
pub fn builder() -> builder::Manifest {
Default::default()
}
}
///The DID of the voting service that holds the board.
///
#[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`
///
#[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`
///
#[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.
///
#[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`
///
#[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`
///
#[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.
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
#[deprecated(note = "superseded by vta/pcs/trustee/justify/0.3")]
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.
///
#[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.
///
#[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`.
///
#[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`.
///
#[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`
///
#[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).
///
#[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`
///
#[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`
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
#[deprecated(note = "superseded by vta/pcs/trustee/justify/0.3")]
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).
///
#[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.
///
#[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.
///
#[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`
///
#[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).
///
#[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.
///
#[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.
///
#[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.
///
#[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.
///
#[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`
///
#[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:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
results_before_close: ::std::result::Result<bool, ::std::string::String>,
revote: ::std::result::Result<super::Revote, ::std::string::String>,
roll: ::std::result::Result<super::RollRule, ::std::string::String>,
secrecy: ::std::result::Result<super::SecrecyLevel, ::std::string::String>,
text_release_threshold: ::std::result::Result<i64, ::std::string::String>,
title: ::std::result::Result<
::std::option::Option<super::ManifestTitle>,
::std::string::String,
>,
trustees:
::std::result::Result<::std::option::Option<super::Trustees>, ::std::string::String>,
voting_closes:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
voting_opens:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
}
impl ::std::default::Default for Manifest {
fn default() -> Self {
Self {
allow_early_close: Err("no value supplied for allow_early_close".to_string()),
ballot_box: Err("no value supplied for ballot_box".to_string()),
binding: Err("no value supplied for binding".to_string()),
board: Err("no value supplied for board".to_string()),
community: Err("no value supplied for community".to_string()),
description: Ok(Default::default()),
election_id: Err("no value supplied for election_id".to_string()),
questions: Err("no value supplied for questions".to_string()),
registration_opens: Err("no value supplied for registration_opens".to_string()),
results_before_close: Err("no value supplied for results_before_close".to_string()),
revote: Err("no value supplied for revote".to_string()),
roll: Err("no value supplied for roll".to_string()),
secrecy: Err("no value supplied for secrecy".to_string()),
text_release_threshold: Err(
"no value supplied for text_release_threshold".to_string()
),
title: Ok(Default::default()),
trustees: Ok(Default::default()),
voting_closes: Err("no value supplied for voting_closes".to_string()),
voting_opens: Err("no value supplied for voting_opens".to_string()),
}
}
}
impl Manifest {
pub fn allow_early_close<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.allow_early_close = value
.try_into()
.map_err(|e| format!("error converting supplied value for allow_early_close: {e}"));
self
}
pub fn ballot_box<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ManifestBallotBox>,
T::Error: ::std::fmt::Display,
{
self.ballot_box = value
.try_into()
.map_err(|e| format!("error converting supplied value for ballot_box: {e}"));
self
}
pub fn binding<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.binding = value
.try_into()
.map_err(|e| format!("error converting supplied value for binding: {e}"));
self
}
pub fn board<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ManifestBoard>,
T::Error: ::std::fmt::Display,
{
self.board = value
.try_into()
.map_err(|e| format!("error converting supplied value for board: {e}"));
self
}
pub fn community<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ManifestCommunity>,
T::Error: ::std::fmt::Display,
{
self.community = value
.try_into()
.map_err(|e| format!("error converting supplied value for community: {e}"));
self
}
pub fn description<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ManifestDescription>>,
T::Error: ::std::fmt::Display,
{
self.description = value
.try_into()
.map_err(|e| format!("error converting supplied value for description: {e}"));
self
}
pub fn election_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ElectionId>,
T::Error: ::std::fmt::Display,
{
self.election_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for election_id: {e}"));
self
}
pub fn questions<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::Question>>,
T::Error: ::std::fmt::Display,
{
self.questions = value
.try_into()
.map_err(|e| format!("error converting supplied value for questions: {e}"));
self
}
pub fn registration_opens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.registration_opens = value.try_into().map_err(|e| {
format!("error converting supplied value for registration_opens: {e}")
});
self
}
pub fn results_before_close<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.results_before_close = value.try_into().map_err(|e| {
format!("error converting supplied value for results_before_close: {e}")
});
self
}
pub fn revote<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Revote>,
T::Error: ::std::fmt::Display,
{
self.revote = value
.try_into()
.map_err(|e| format!("error converting supplied value for revote: {e}"));
self
}
pub fn roll<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::RollRule>,
T::Error: ::std::fmt::Display,
{
self.roll = value
.try_into()
.map_err(|e| format!("error converting supplied value for roll: {e}"));
self
}
pub fn secrecy<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::SecrecyLevel>,
T::Error: ::std::fmt::Display,
{
self.secrecy = value
.try_into()
.map_err(|e| format!("error converting supplied value for secrecy: {e}"));
self
}
pub fn text_release_threshold<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<i64>,
T::Error: ::std::fmt::Display,
{
self.text_release_threshold = value.try_into().map_err(|e| {
format!("error converting supplied value for text_release_threshold: {e}")
});
self
}
pub fn title<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ManifestTitle>>,
T::Error: ::std::fmt::Display,
{
self.title = value
.try_into()
.map_err(|e| format!("error converting supplied value for title: {e}"));
self
}
pub fn trustees<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Trustees>>,
T::Error: ::std::fmt::Display,
{
self.trustees = value
.try_into()
.map_err(|e| format!("error converting supplied value for trustees: {e}"));
self
}
pub fn voting_closes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.voting_closes = value
.try_into()
.map_err(|e| format!("error converting supplied value for voting_closes: {e}"));
self
}
pub fn voting_opens<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.voting_opens = value
.try_into()
.map_err(|e| format!("error converting supplied value for voting_opens: {e}"));
self
}
}
impl ::std::convert::TryFrom<Manifest> for super::Manifest {
type Error = super::error::ConversionError;
fn try_from(value: Manifest) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
allow_early_close: value.allow_early_close?,
ballot_box: value.ballot_box?,
binding: value.binding?,
board: value.board?,
community: value.community?,
description: value.description?,
election_id: value.election_id?,
questions: value.questions?,
registration_opens: value.registration_opens?,
results_before_close: value.results_before_close?,
revote: value.revote?,
roll: value.roll?,
secrecy: value.secrecy?,
text_release_threshold: value.text_release_threshold?,
title: value.title?,
trustees: value.trustees?,
voting_closes: value.voting_closes?,
voting_opens: value.voting_opens?,
})
}
}
impl ::std::convert::From<super::Manifest> for Manifest {
fn from(value: super::Manifest) -> Self {
Self {
allow_early_close: Ok(value.allow_early_close),
ballot_box: Ok(value.ballot_box),
binding: Ok(value.binding),
board: Ok(value.board),
community: Ok(value.community),
description: Ok(value.description),
election_id: Ok(value.election_id),
questions: Ok(value.questions),
registration_opens: Ok(value.registration_opens),
results_before_close: Ok(value.results_before_close),
revote: Ok(value.revote),
roll: Ok(value.roll),
secrecy: Ok(value.secrecy),
text_release_threshold: Ok(value.text_release_threshold),
title: Ok(value.title),
trustees: Ok(value.trustees),
voting_closes: Ok(value.voting_closes),
voting_opens: Ok(value.voting_opens),
}
}
}
#[derive(Clone, Debug)]
pub struct ManifestBoard {
auditors:
::std::result::Result<Vec<super::ManifestBoardAuditorsItem>, ::std::string::String>,
visibility: ::std::result::Result<super::BoardVisibility, ::std::string::String>,
}
impl ::std::default::Default for ManifestBoard {
fn default() -> Self {
Self {
auditors: Err("no value supplied for auditors".to_string()),
visibility: Err("no value supplied for visibility".to_string()),
}
}
}
impl ManifestBoard {
pub fn auditors<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<Vec<super::ManifestBoardAuditorsItem>>,
T::Error: ::std::fmt::Display,
{
self.auditors = value
.try_into()
.map_err(|e| format!("error converting supplied value for auditors: {e}"));
self
}
pub fn visibility<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::BoardVisibility>,
T::Error: ::std::fmt::Display,
{
self.visibility = value
.try_into()
.map_err(|e| format!("error converting supplied value for visibility: {e}"));
self
}
}
impl ::std::convert::TryFrom<ManifestBoard> for super::ManifestBoard {
type Error = super::error::ConversionError;
fn try_from(
value: ManifestBoard,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
auditors: value.auditors?,
visibility: value.visibility?,
})
}
}
impl ::std::convert::From<super::ManifestBoard> for ManifestBoard {
fn from(value: super::ManifestBoard) -> Self {
Self {
auditors: Ok(value.auditors),
visibility: Ok(value.visibility),
}
}
}
#[derive(Clone, Debug)]
pub struct Payload {
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.2";
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(
"{\"$defs\":{\"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).\",\"enum\":[\"public\",\"private\"],\"title\":\"BoardVisibility\",\"type\":\"string\"},\"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.\",\"pattern\":\"^[A-Za-z0-9._-]{1,128}$\",\"title\":\"ElectionId\",\"type\":\"string\"},\"Ext\":{\"additionalProperties\":true,\"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.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"Key\":{\"description\":\"A question or option key, unique within its manifest or question.\",\"pattern\":\"^[A-Za-z0-9._-]{1,64}$\",\"title\":\"Key\",\"type\":\"string\"},\"Manifest\":{\"additionalProperties\":false,\"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).\",\"properties\":{\"allowEarlyClose\":{\"type\":\"boolean\"},\"ballotBox\":{\"description\":\"The DID of the voting service that holds the board.\",\"maxLength\":2048,\"minLength\":1,\"type\":\"string\"},\"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\":{\"additionalProperties\":false,\"properties\":{\"auditors\":{\"items\":{\"maxLength\":2048,\"minLength\":1,\"type\":\"string\"},\"type\":\"array\",\"uniqueItems\":true},\"visibility\":{\"$ref\":\"#/$defs/BoardVisibility\"}},\"required\":[\"visibility\",\"auditors\"],\"type\":\"object\"},\"community\":{\"description\":\"The community's DID.\",\"maxLength\":2048,\"minLength\":1,\"type\":\"string\"},\"description\":{\"maxLength\":8192,\"type\":\"string\"},\"electionId\":{\"$ref\":\"#/$defs/ElectionId\"},\"questions\":{\"items\":{\"$ref\":\"#/$defs/Question\"},\"maxItems\":128,\"minItems\":1,\"type\":\"array\"},\"registrationOpens\":{\"format\":\"date-time\",\"type\":\"string\"},\"resultsBeforeClose\":{\"description\":\"Open elections only: whether running totals may be read while voting is open (VTI-VOT-061).\",\"type\":\"boolean\"},\"revote\":{\"$ref\":\"#/$defs/Revote\"},\"roll\":{\"$ref\":\"#/$defs/RollRule\"},\"secrecy\":{\"$ref\":\"#/$defs/SecrecyLevel\"},\"textReleaseThreshold\":{\"description\":\"Counted ballots required before any text answer is disclosed (VTI-VOT-065).\",\"minimum\":10,\"type\":\"integer\"},\"title\":{\"maxLength\":512,\"type\":\"string\"},\"trustees\":{\"$ref\":\"#/$defs/Trustees\"},\"votingCloses\":{\"format\":\"date-time\",\"type\":\"string\"},\"votingOpens\":{\"format\":\"date-time\",\"type\":\"string\"}},\"required\":[\"electionId\",\"community\",\"questions\",\"secrecy\",\"roll\",\"registrationOpens\",\"votingOpens\",\"votingCloses\",\"revote\",\"board\",\"ballotBox\",\"binding\",\"allowEarlyClose\",\"resultsBeforeClose\",\"textReleaseThreshold\"],\"title\":\"Manifest\",\"type\":\"object\"},\"Question\":{\"description\":\"One question. Tagged union over `type`.\",\"oneOf\":[{\"additionalProperties\":false,\"description\":\"Select between `minSelections` and `maxSelections` of `options`. A yes/no/abstain motion is a choice of exactly one of three.\",\"properties\":{\"key\":{\"$ref\":\"#/$defs/Key\"},\"maxSelections\":{\"minimum\":1,\"type\":\"integer\"},\"minSelections\":{\"minimum\":0,\"type\":\"integer\"},\"optional\":{\"type\":\"boolean\"},\"options\":{\"items\":{\"$ref\":\"#/$defs/QuestionOption\"},\"maxItems\":256,\"minItems\":2,\"type\":\"array\"},\"text\":{\"maxLength\":2048,\"type\":\"string\"},\"type\":{\"const\":\"choice\"}},\"required\":[\"key\",\"type\",\"options\",\"minSelections\",\"maxSelections\",\"optional\"],\"title\":\"ChoiceQuestion\",\"type\":\"object\"},{\"additionalProperties\":false,\"description\":\"Order `options`; a ballot ranks every option or, when `partial` is true, a prefix of them.\",\"properties\":{\"key\":{\"$ref\":\"#/$defs/Key\"},\"optional\":{\"type\":\"boolean\"},\"options\":{\"items\":{\"$ref\":\"#/$defs/QuestionOption\"},\"maxItems\":64,\"minItems\":2,\"type\":\"array\"},\"partial\":{\"type\":\"boolean\"},\"text\":{\"maxLength\":2048,\"type\":\"string\"},\"type\":{\"const\":\"ranking\"}},\"required\":[\"key\",\"type\",\"options\",\"partial\",\"optional\"],\"title\":\"RankingQuestion\",\"type\":\"object\"},{\"additionalProperties\":false,\"description\":\"Give each option an integer score within [min, max].\",\"properties\":{\"key\":{\"$ref\":\"#/$defs/Key\"},\"max\":{\"type\":\"integer\"},\"min\":{\"type\":\"integer\"},\"optional\":{\"type\":\"boolean\"},\"options\":{\"items\":{\"$ref\":\"#/$defs/QuestionOption\"},\"maxItems\":256,\"minItems\":1,\"type\":\"array\"},\"text\":{\"maxLength\":2048,\"type\":\"string\"},\"type\":{\"const\":\"score\"}},\"required\":[\"key\",\"type\",\"options\",\"min\",\"max\",\"optional\"],\"title\":\"ScoreQuestion\",\"type\":\"object\"},{\"additionalProperties\":false,\"description\":\"Free text of at most `maxLength` characters.\",\"properties\":{\"key\":{\"$ref\":\"#/$defs/Key\"},\"maxLength\":{\"maximum\":4096,\"minimum\":1,\"type\":\"integer\"},\"optional\":{\"type\":\"boolean\"},\"text\":{\"maxLength\":2048,\"type\":\"string\"},\"type\":{\"const\":\"text\"}},\"required\":[\"key\",\"type\",\"maxLength\",\"optional\"],\"title\":\"TextQuestion\",\"type\":\"object\"}],\"title\":\"Question\"},\"QuestionOption\":{\"additionalProperties\":false,\"properties\":{\"key\":{\"$ref\":\"#/$defs/Key\"},\"label\":{\"description\":\"Display text. Absent from a manifest registered with a ballot box that holds no question text (VTI-VOT-014).\",\"maxLength\":512,\"type\":\"string\"}},\"required\":[\"key\"],\"title\":\"QuestionOption\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"properties\":{\"document\":{\"description\":\"The voting/trustees/justify request, signed as the trustee.\",\"properties\":{\"expiresAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"id\":{\"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}$\",\"type\":\"string\"},\"issuedAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"issuer\":{\"description\":\"The signer.\",\"maxLength\":2048,\"minLength\":1,\"type\":\"string\"},\"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.\",\"maxLength\":2048,\"minLength\":1,\"type\":\"string\"},\"type\":{\"const\":\"https://trusttasks.org/spec/voting/trustees/justify/0.1\"}},\"required\":[\"id\",\"type\",\"issuer\",\"recipient\",\"issuedAt\",\"payload\",\"proof\"],\"title\":\"JustifyDocument\",\"type\":\"object\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"}},\"required\":[\"document\"],\"title\":\"VTA PCS — Trustee Justify — response payload\",\"type\":\"object\"},\"Revote\":{\"description\":\"What a later, different ballot under one ticket does: `replace` the earlier one, or be refused (`refuse`) (VTI-VOT-041).\",\"enum\":[\"replace\",\"refuse\"],\"title\":\"Revote\",\"type\":\"string\"},\"RollRule\":{\"additionalProperties\":false,\"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.\",\"properties\":{\"listed\":{\"items\":{\"description\":\"A DID enfranchised by name.\",\"maxLength\":2048,\"minLength\":1,\"type\":\"string\"},\"type\":\"array\",\"uniqueItems\":true},\"rule\":{\"enum\":[\"members\",\"membersAndListed\",\"listed\"],\"type\":\"string\"}},\"required\":[\"rule\"],\"title\":\"RollRule\",\"type\":\"object\"},\"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).\",\"enum\":[\"open\",\"sealed\",\"talliedEncrypted\"],\"title\":\"SecrecyLevel\",\"type\":\"string\"},\"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.\",\"minProperties\":1,\"title\":\"SignedRequest\",\"type\":\"object\"},\"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.\",\"items\":{\"$ref\":\"#/$defs/SignedRequest\"},\"maxItems\":4224,\"minItems\":1,\"title\":\"TrusteeCeremony\",\"type\":\"array\"},\"TrusteeIndex\":{\"description\":\"A trustee's index: its position in the manifest's `trustees.dids`, counting from 1.\",\"maximum\":64,\"minimum\":1,\"title\":\"TrusteeIndex\",\"type\":\"integer\"},\"Trustees\":{\"additionalProperties\":false,\"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.\",\"properties\":{\"dids\":{\"items\":{\"maxLength\":2048,\"minLength\":1,\"type\":\"string\"},\"minItems\":2,\"type\":\"array\",\"uniqueItems\":true},\"threshold\":{\"minimum\":2,\"type\":\"integer\"}},\"required\":[\"dids\",\"threshold\"],\"title\":\"Trustees\",\"type\":\"object\"}},\"$id\":\"https://trusttasks.org/spec/vta/pcs/trustee/justify/0.2\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"additionalProperties\":false,\"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.\",\"properties\":{\"ceremony\":{\"$ref\":\"#/$defs/TrusteeCeremony\",\"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.\"},\"community\":{\"description\":\"The community's DID.\",\"maxLength\":2048,\"minLength\":1,\"type\":\"string\"},\"contextId\":{\"description\":\"The VTA context the trustee's keys live in.\",\"maxLength\":256,\"minLength\":1,\"type\":\"string\"},\"electionId\":{\"$ref\":\"#/$defs/ElectionId\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"manifest\":{\"$ref\":\"#/$defs/Manifest\"},\"recipient\":{\"$ref\":\"#/$defs/TrusteeIndex\"},\"trustee\":{\"description\":\"The trustee's DID: a persona this VTA holds, named in the manifest's `trustees.dids`.\",\"maxLength\":2048,\"minLength\":1,\"type\":\"string\"}},\"required\":[\"contextId\",\"community\",\"electionId\",\"trustee\",\"manifest\",\"ceremony\",\"recipient\"],\"title\":\"VTA PCS — Trustee Justify — payload\",\"type\":\"object\"}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/vta/pcs/trustee/justify/0.2#response";
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"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).\",\"enum\":[\"public\",\"private\"],\"title\":\"BoardVisibility\",\"type\":\"string\"},\"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.\",\"pattern\":\"^[A-Za-z0-9._-]{1,128}$\",\"title\":\"ElectionId\",\"type\":\"string\"},\"Ext\":{\"additionalProperties\":true,\"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.\",\"minProperties\":1,\"propertyNames\":{\"pattern\":\"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"},\"title\":\"Ext\",\"type\":\"object\"},\"Key\":{\"description\":\"A question or option key, unique within its manifest or question.\",\"pattern\":\"^[A-Za-z0-9._-]{1,64}$\",\"title\":\"Key\",\"type\":\"string\"},\"Manifest\":{\"additionalProperties\":false,\"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).\",\"properties\":{\"allowEarlyClose\":{\"type\":\"boolean\"},\"ballotBox\":{\"description\":\"The DID of the voting service that holds the board.\",\"maxLength\":2048,\"minLength\":1,\"type\":\"string\"},\"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\":{\"additionalProperties\":false,\"properties\":{\"auditors\":{\"items\":{\"maxLength\":2048,\"minLength\":1,\"type\":\"string\"},\"type\":\"array\",\"uniqueItems\":true},\"visibility\":{\"$ref\":\"#/$defs/BoardVisibility\"}},\"required\":[\"visibility\",\"auditors\"],\"type\":\"object\"},\"community\":{\"description\":\"The community's DID.\",\"maxLength\":2048,\"minLength\":1,\"type\":\"string\"},\"description\":{\"maxLength\":8192,\"type\":\"string\"},\"electionId\":{\"$ref\":\"#/$defs/ElectionId\"},\"questions\":{\"items\":{\"$ref\":\"#/$defs/Question\"},\"maxItems\":128,\"minItems\":1,\"type\":\"array\"},\"registrationOpens\":{\"format\":\"date-time\",\"type\":\"string\"},\"resultsBeforeClose\":{\"description\":\"Open elections only: whether running totals may be read while voting is open (VTI-VOT-061).\",\"type\":\"boolean\"},\"revote\":{\"$ref\":\"#/$defs/Revote\"},\"roll\":{\"$ref\":\"#/$defs/RollRule\"},\"secrecy\":{\"$ref\":\"#/$defs/SecrecyLevel\"},\"textReleaseThreshold\":{\"description\":\"Counted ballots required before any text answer is disclosed (VTI-VOT-065).\",\"minimum\":10,\"type\":\"integer\"},\"title\":{\"maxLength\":512,\"type\":\"string\"},\"trustees\":{\"$ref\":\"#/$defs/Trustees\"},\"votingCloses\":{\"format\":\"date-time\",\"type\":\"string\"},\"votingOpens\":{\"format\":\"date-time\",\"type\":\"string\"}},\"required\":[\"electionId\",\"community\",\"questions\",\"secrecy\",\"roll\",\"registrationOpens\",\"votingOpens\",\"votingCloses\",\"revote\",\"board\",\"ballotBox\",\"binding\",\"allowEarlyClose\",\"resultsBeforeClose\",\"textReleaseThreshold\"],\"title\":\"Manifest\",\"type\":\"object\"},\"Question\":{\"description\":\"One question. Tagged union over `type`.\",\"oneOf\":[{\"additionalProperties\":false,\"description\":\"Select between `minSelections` and `maxSelections` of `options`. A yes/no/abstain motion is a choice of exactly one of three.\",\"properties\":{\"key\":{\"$ref\":\"#/$defs/Key\"},\"maxSelections\":{\"minimum\":1,\"type\":\"integer\"},\"minSelections\":{\"minimum\":0,\"type\":\"integer\"},\"optional\":{\"type\":\"boolean\"},\"options\":{\"items\":{\"$ref\":\"#/$defs/QuestionOption\"},\"maxItems\":256,\"minItems\":2,\"type\":\"array\"},\"text\":{\"maxLength\":2048,\"type\":\"string\"},\"type\":{\"const\":\"choice\"}},\"required\":[\"key\",\"type\",\"options\",\"minSelections\",\"maxSelections\",\"optional\"],\"title\":\"ChoiceQuestion\",\"type\":\"object\"},{\"additionalProperties\":false,\"description\":\"Order `options`; a ballot ranks every option or, when `partial` is true, a prefix of them.\",\"properties\":{\"key\":{\"$ref\":\"#/$defs/Key\"},\"optional\":{\"type\":\"boolean\"},\"options\":{\"items\":{\"$ref\":\"#/$defs/QuestionOption\"},\"maxItems\":64,\"minItems\":2,\"type\":\"array\"},\"partial\":{\"type\":\"boolean\"},\"text\":{\"maxLength\":2048,\"type\":\"string\"},\"type\":{\"const\":\"ranking\"}},\"required\":[\"key\",\"type\",\"options\",\"partial\",\"optional\"],\"title\":\"RankingQuestion\",\"type\":\"object\"},{\"additionalProperties\":false,\"description\":\"Give each option an integer score within [min, max].\",\"properties\":{\"key\":{\"$ref\":\"#/$defs/Key\"},\"max\":{\"type\":\"integer\"},\"min\":{\"type\":\"integer\"},\"optional\":{\"type\":\"boolean\"},\"options\":{\"items\":{\"$ref\":\"#/$defs/QuestionOption\"},\"maxItems\":256,\"minItems\":1,\"type\":\"array\"},\"text\":{\"maxLength\":2048,\"type\":\"string\"},\"type\":{\"const\":\"score\"}},\"required\":[\"key\",\"type\",\"options\",\"min\",\"max\",\"optional\"],\"title\":\"ScoreQuestion\",\"type\":\"object\"},{\"additionalProperties\":false,\"description\":\"Free text of at most `maxLength` characters.\",\"properties\":{\"key\":{\"$ref\":\"#/$defs/Key\"},\"maxLength\":{\"maximum\":4096,\"minimum\":1,\"type\":\"integer\"},\"optional\":{\"type\":\"boolean\"},\"text\":{\"maxLength\":2048,\"type\":\"string\"},\"type\":{\"const\":\"text\"}},\"required\":[\"key\",\"type\",\"maxLength\",\"optional\"],\"title\":\"TextQuestion\",\"type\":\"object\"}],\"title\":\"Question\"},\"QuestionOption\":{\"additionalProperties\":false,\"properties\":{\"key\":{\"$ref\":\"#/$defs/Key\"},\"label\":{\"description\":\"Display text. Absent from a manifest registered with a ballot box that holds no question text (VTI-VOT-014).\",\"maxLength\":512,\"type\":\"string\"}},\"required\":[\"key\"],\"title\":\"QuestionOption\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"properties\":{\"document\":{\"description\":\"The voting/trustees/justify request, signed as the trustee.\",\"properties\":{\"expiresAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"id\":{\"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}$\",\"type\":\"string\"},\"issuedAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"issuer\":{\"description\":\"The signer.\",\"maxLength\":2048,\"minLength\":1,\"type\":\"string\"},\"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.\",\"maxLength\":2048,\"minLength\":1,\"type\":\"string\"},\"type\":{\"const\":\"https://trusttasks.org/spec/voting/trustees/justify/0.1\"}},\"required\":[\"id\",\"type\",\"issuer\",\"recipient\",\"issuedAt\",\"payload\",\"proof\"],\"title\":\"JustifyDocument\",\"type\":\"object\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"}},\"required\":[\"document\"],\"title\":\"VTA PCS — Trustee Justify — response payload\",\"type\":\"object\"},\"Revote\":{\"description\":\"What a later, different ballot under one ticket does: `replace` the earlier one, or be refused (`refuse`) (VTI-VOT-041).\",\"enum\":[\"replace\",\"refuse\"],\"title\":\"Revote\",\"type\":\"string\"},\"RollRule\":{\"additionalProperties\":false,\"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.\",\"properties\":{\"listed\":{\"items\":{\"description\":\"A DID enfranchised by name.\",\"maxLength\":2048,\"minLength\":1,\"type\":\"string\"},\"type\":\"array\",\"uniqueItems\":true},\"rule\":{\"enum\":[\"members\",\"membersAndListed\",\"listed\"],\"type\":\"string\"}},\"required\":[\"rule\"],\"title\":\"RollRule\",\"type\":\"object\"},\"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).\",\"enum\":[\"open\",\"sealed\",\"talliedEncrypted\"],\"title\":\"SecrecyLevel\",\"type\":\"string\"},\"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.\",\"minProperties\":1,\"title\":\"SignedRequest\",\"type\":\"object\"},\"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.\",\"items\":{\"$ref\":\"#/$defs/SignedRequest\"},\"maxItems\":4224,\"minItems\":1,\"title\":\"TrusteeCeremony\",\"type\":\"array\"},\"TrusteeIndex\":{\"description\":\"A trustee's index: its position in the manifest's `trustees.dids`, counting from 1.\",\"maximum\":64,\"minimum\":1,\"title\":\"TrusteeIndex\",\"type\":\"integer\"},\"Trustees\":{\"additionalProperties\":false,\"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.\",\"properties\":{\"dids\":{\"items\":{\"maxLength\":2048,\"minLength\":1,\"type\":\"string\"},\"minItems\":2,\"type\":\"array\",\"uniqueItems\":true},\"threshold\":{\"minimum\":2,\"type\":\"integer\"}},\"required\":[\"dids\",\"threshold\"],\"title\":\"Trustees\",\"type\":\"object\"}},\"$ref\":\"#/$defs/Response\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\"}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// The earlier `MAJOR.MINOR` of this slug that this version declares it
/// extends (front matter `extends`, SPEC §5.2 "Declared extension"), or
/// `None`. Only the direct declaration; walk a chain with
/// [`crate::extension::extends_for`].
pub const EXTENDS: Option<&str> = None;
/// 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,
};
}