//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `policy/list`. 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 policy/list/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())
}
}
}
///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())
})
}
}
///`Payload`
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
#[deprecated(note = "superseded by policy/list/0.3")]
pub struct Payload {
#[serde(
rename = "contextId",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub context_id: ::std::option::Option<PayloadContextId>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub cursor: ::std::option::Option<::std::string::String>,
#[serde(rename = "enabledOnly", default)]
pub enabled_only: bool,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
#[serde(
rename = "pageSize",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub page_size: ::std::option::Option<::std::num::NonZeroU64>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
context_id: Default::default(),
cursor: Default::default(),
enabled_only: Default::default(),
ext: Default::default(),
page_size: Default::default(),
}
}
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///`PayloadContextId`
///
#[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() < 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())
})
}
}
///`PolicyModule`
///
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct PolicyModule {
///List of trust contexts this policy applies to. Empty array = applies to all contexts (the default policy).
#[serde(
rename = "appliesTo",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub applies_to: ::std::option::Option<Vec<::std::string::String>>,
#[serde(rename = "createdAt")]
pub created_at: ::chrono::DateTime<::chrono::offset::Utc>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub description: ::std::option::Option<PolicyModuleDescription>,
#[serde(default = "defaults::default_bool::<true>")]
pub enabled: bool,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
pub id: PolicyModuleId,
///Rego source code. The maintainer's evaluator entry point is the package's `decision` rule, returning a PolicyDecision.
pub module: PolicyModuleModule,
///Human-readable name (e.g. "default vault policy", "bank-site step-up").
pub name: PolicyModuleName,
///When multiple policies match a request, evaluation order is by priority descending. The first to return a non-`null` decision wins.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub priority: ::std::option::Option<i64>,
#[serde(rename = "updatedAt")]
pub updated_at: ::chrono::DateTime<::chrono::offset::Utc>,
pub version: u64,
}
impl PolicyModule {
pub fn builder() -> builder::PolicyModule {
Default::default()
}
}
///`PolicyModuleDescription`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PolicyModuleDescription(::std::string::String);
impl ::std::ops::Deref for PolicyModuleDescription {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PolicyModuleDescription> for ::std::string::String {
fn from(value: PolicyModuleDescription) -> Self {
value.0
}
}
impl ::std::str::FromStr for PolicyModuleDescription {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 1024usize {
return Err("longer than 1024 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PolicyModuleDescription {
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 PolicyModuleDescription {
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 PolicyModuleDescription {
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 PolicyModuleDescription {
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())
})
}
}
///`PolicyModuleId`
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PolicyModuleId(::std::string::String);
impl ::std::ops::Deref for PolicyModuleId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PolicyModuleId> for ::std::string::String {
fn from(value: PolicyModuleId) -> Self {
value.0
}
}
impl ::std::str::FromStr for PolicyModuleId {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PolicyModuleId {
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 PolicyModuleId {
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 PolicyModuleId {
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 PolicyModuleId {
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())
})
}
}
///Rego source code. The maintainer's evaluator entry point is the package's `decision` rule, returning a PolicyDecision.
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PolicyModuleModule(::std::string::String);
impl ::std::ops::Deref for PolicyModuleModule {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PolicyModuleModule> for ::std::string::String {
fn from(value: PolicyModuleModule) -> Self {
value.0
}
}
impl ::std::str::FromStr for PolicyModuleModule {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PolicyModuleModule {
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 PolicyModuleModule {
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 PolicyModuleModule {
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 PolicyModuleModule {
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())
})
}
}
///Human-readable name (e.g. "default vault policy", "bank-site step-up").
///
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PolicyModuleName(::std::string::String);
impl ::std::ops::Deref for PolicyModuleName {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PolicyModuleName> for ::std::string::String {
fn from(value: PolicyModuleName) -> Self {
value.0
}
}
impl ::std::str::FromStr for PolicyModuleName {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 128usize {
return Err("longer than 128 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 PolicyModuleName {
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 PolicyModuleName {
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 PolicyModuleName {
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 PolicyModuleName {
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 policy/list/0.3")]
pub struct Response {
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub cursor: ::std::option::Option<::std::string::String>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
pub policies: ::std::vec::Vec<PolicyModule>,
pub truncated: bool,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Payload {
context_id: ::std::result::Result<
::std::option::Option<super::PayloadContextId>,
::std::string::String,
>,
cursor: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
enabled_only: ::std::result::Result<bool, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
page_size: ::std::result::Result<
::std::option::Option<::std::num::NonZeroU64>,
::std::string::String,
>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
context_id: Ok(Default::default()),
cursor: Ok(Default::default()),
enabled_only: Ok(Default::default()),
ext: Ok(Default::default()),
page_size: Ok(Default::default()),
}
}
}
impl Payload {
pub fn context_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<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 cursor<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.cursor = value
.try_into()
.map_err(|e| format!("error converting supplied value for cursor: {e}"));
self
}
pub fn enabled_only<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.enabled_only = value
.try_into()
.map_err(|e| format!("error converting supplied value for enabled_only: {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 page_size<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::num::NonZeroU64>>,
T::Error: ::std::fmt::Display,
{
self.page_size = value
.try_into()
.map_err(|e| format!("error converting supplied value for page_size: {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 {
context_id: value.context_id?,
cursor: value.cursor?,
enabled_only: value.enabled_only?,
ext: value.ext?,
page_size: value.page_size?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
context_id: Ok(value.context_id),
cursor: Ok(value.cursor),
enabled_only: Ok(value.enabled_only),
ext: Ok(value.ext),
page_size: Ok(value.page_size),
}
}
}
#[derive(Clone, Debug)]
pub struct PolicyModule {
applies_to: ::std::result::Result<
::std::option::Option<Vec<::std::string::String>>,
::std::string::String,
>,
created_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
description: ::std::result::Result<
::std::option::Option<super::PolicyModuleDescription>,
::std::string::String,
>,
enabled: ::std::result::Result<bool, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
id: ::std::result::Result<super::PolicyModuleId, ::std::string::String>,
module: ::std::result::Result<super::PolicyModuleModule, ::std::string::String>,
name: ::std::result::Result<super::PolicyModuleName, ::std::string::String>,
priority: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
updated_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
version: ::std::result::Result<u64, ::std::string::String>,
}
impl ::std::default::Default for PolicyModule {
fn default() -> Self {
Self {
applies_to: Ok(Default::default()),
created_at: Err("no value supplied for created_at".to_string()),
description: Ok(Default::default()),
enabled: Ok(super::defaults::default_bool::<true>()),
ext: Ok(Default::default()),
id: Err("no value supplied for id".to_string()),
module: Err("no value supplied for module".to_string()),
name: Err("no value supplied for name".to_string()),
priority: Ok(Default::default()),
updated_at: Err("no value supplied for updated_at".to_string()),
version: Err("no value supplied for version".to_string()),
}
}
}
impl PolicyModule {
pub fn applies_to<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<Vec<::std::string::String>>>,
T::Error: ::std::fmt::Display,
{
self.applies_to = value
.try_into()
.map_err(|e| format!("error converting supplied value for applies_to: {e}"));
self
}
pub fn created_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.created_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for created_at: {e}"));
self
}
pub fn description<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PolicyModuleDescription>>,
T::Error: ::std::fmt::Display,
{
self.description = value
.try_into()
.map_err(|e| format!("error converting supplied value for description: {e}"));
self
}
pub fn enabled<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.enabled = value
.try_into()
.map_err(|e| format!("error converting supplied value for enabled: {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 id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PolicyModuleId>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn module<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PolicyModuleModule>,
T::Error: ::std::fmt::Display,
{
self.module = value
.try_into()
.map_err(|e| format!("error converting supplied value for module: {e}"));
self
}
pub fn name<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PolicyModuleName>,
T::Error: ::std::fmt::Display,
{
self.name = value
.try_into()
.map_err(|e| format!("error converting supplied value for name: {e}"));
self
}
pub fn priority<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.priority = value
.try_into()
.map_err(|e| format!("error converting supplied value for priority: {e}"));
self
}
pub fn updated_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::chrono::DateTime<::chrono::offset::Utc>>,
T::Error: ::std::fmt::Display,
{
self.updated_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for updated_at: {e}"));
self
}
pub fn version<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.version = value
.try_into()
.map_err(|e| format!("error converting supplied value for version: {e}"));
self
}
}
impl ::std::convert::TryFrom<PolicyModule> for super::PolicyModule {
type Error = super::error::ConversionError;
fn try_from(
value: PolicyModule,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
applies_to: value.applies_to?,
created_at: value.created_at?,
description: value.description?,
enabled: value.enabled?,
ext: value.ext?,
id: value.id?,
module: value.module?,
name: value.name?,
priority: value.priority?,
updated_at: value.updated_at?,
version: value.version?,
})
}
}
impl ::std::convert::From<super::PolicyModule> for PolicyModule {
fn from(value: super::PolicyModule) -> Self {
Self {
applies_to: Ok(value.applies_to),
created_at: Ok(value.created_at),
description: Ok(value.description),
enabled: Ok(value.enabled),
ext: Ok(value.ext),
id: Ok(value.id),
module: Ok(value.module),
name: Ok(value.name),
priority: Ok(value.priority),
updated_at: Ok(value.updated_at),
version: Ok(value.version),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
cursor: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
policies:
::std::result::Result<::std::vec::Vec<super::PolicyModule>, ::std::string::String>,
truncated: ::std::result::Result<bool, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
cursor: Ok(Default::default()),
ext: Ok(Default::default()),
policies: Err("no value supplied for policies".to_string()),
truncated: Err("no value supplied for truncated".to_string()),
}
}
}
impl Response {
pub fn cursor<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.cursor = value
.try_into()
.map_err(|e| format!("error converting supplied value for cursor: {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 policies<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::PolicyModule>>,
T::Error: ::std::fmt::Display,
{
self.policies = value
.try_into()
.map_err(|e| format!("error converting supplied value for policies: {e}"));
self
}
pub fn truncated<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.truncated = value
.try_into()
.map_err(|e| format!("error converting supplied value for truncated: {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 {
cursor: value.cursor?,
ext: value.ext?,
policies: value.policies?,
truncated: value.truncated?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
cursor: Ok(value.cursor),
ext: Ok(value.ext),
policies: Ok(value.policies),
truncated: Ok(value.truncated),
}
}
}
}
/// Generation of default values for serde.
pub mod defaults {
pub(super) fn default_bool<const V: bool>() -> bool {
V
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/policy/list/0.2";
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"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\"},\"PolicyModule\":{\"additionalProperties\":false,\"properties\":{\"appliesTo\":{\"description\":\"List of trust contexts this policy applies to. Empty array = applies to all contexts (the default policy).\",\"items\":{\"type\":\"string\"},\"type\":\"array\",\"uniqueItems\":true},\"createdAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"description\":{\"maxLength\":1024,\"type\":\"string\"},\"enabled\":{\"default\":true,\"type\":\"boolean\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"id\":{\"minLength\":1,\"type\":\"string\"},\"module\":{\"description\":\"Rego source code. The maintainer's evaluator entry point is the package's `decision` rule, returning a PolicyDecision.\",\"minLength\":1,\"type\":\"string\"},\"name\":{\"description\":\"Human-readable name (e.g. \\\"default vault policy\\\", \\\"bank-site step-up\\\").\",\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"priority\":{\"description\":\"When multiple policies match a request, evaluation order is by priority descending. The first to return a non-`null` decision wins.\",\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"updatedAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"version\":{\"minimum\":0,\"type\":\"integer\"}},\"required\":[\"id\",\"name\",\"module\",\"version\",\"createdAt\",\"updatedAt\"],\"title\":\"PolicyModule\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"properties\":{\"cursor\":{\"type\":\"string\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"policies\":{\"items\":{\"$ref\":\"#/$defs/PolicyModule\"},\"type\":\"array\"},\"truncated\":{\"type\":\"boolean\"}},\"required\":[\"policies\",\"truncated\"],\"title\":\"Policy List — response payload\",\"type\":\"object\"}},\"$id\":\"https://trusttasks.org/spec/policy/list/0.2\",\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"additionalProperties\":false,\"properties\":{\"contextId\":{\"minLength\":1,\"type\":\"string\"},\"cursor\":{\"type\":\"string\"},\"enabledOnly\":{\"default\":false,\"type\":\"boolean\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"pageSize\":{\"maximum\":1000,\"minimum\":1,\"type\":\"integer\"}},\"title\":\"Policy List — payload\",\"type\":\"object\"}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/policy/list/0.2#response";
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\"$defs\":{\"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\"},\"PolicyModule\":{\"additionalProperties\":false,\"properties\":{\"appliesTo\":{\"description\":\"List of trust contexts this policy applies to. Empty array = applies to all contexts (the default policy).\",\"items\":{\"type\":\"string\"},\"type\":\"array\",\"uniqueItems\":true},\"createdAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"description\":{\"maxLength\":1024,\"type\":\"string\"},\"enabled\":{\"default\":true,\"type\":\"boolean\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"id\":{\"minLength\":1,\"type\":\"string\"},\"module\":{\"description\":\"Rego source code. The maintainer's evaluator entry point is the package's `decision` rule, returning a PolicyDecision.\",\"minLength\":1,\"type\":\"string\"},\"name\":{\"description\":\"Human-readable name (e.g. \\\"default vault policy\\\", \\\"bank-site step-up\\\").\",\"maxLength\":128,\"minLength\":1,\"type\":\"string\"},\"priority\":{\"description\":\"When multiple policies match a request, evaluation order is by priority descending. The first to return a non-`null` decision wins.\",\"maximum\":1000,\"minimum\":0,\"type\":\"integer\"},\"updatedAt\":{\"format\":\"date-time\",\"type\":\"string\"},\"version\":{\"minimum\":0,\"type\":\"integer\"}},\"required\":[\"id\",\"name\",\"module\",\"version\",\"createdAt\",\"updatedAt\"],\"title\":\"PolicyModule\",\"type\":\"object\"},\"Response\":{\"$anchor\":\"response\",\"additionalProperties\":false,\"properties\":{\"cursor\":{\"type\":\"string\"},\"ext\":{\"$ref\":\"#/$defs/Ext\"},\"policies\":{\"items\":{\"$ref\":\"#/$defs/PolicyModule\"},\"type\":\"array\"},\"truncated\":{\"type\":\"boolean\"}},\"required\":[\"policies\",\"truncated\"],\"title\":\"Policy List — response payload\",\"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] = &[];