//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `vtc/groups/bindings/add`. Version: `0.1`.
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
///`BindingId`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "BindingId",
/// "type": "string",
/// "pattern": "^gb_[A-Za-z0-9_-]{16,64}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct BindingId(::std::string::String);
impl ::std::ops::Deref for BindingId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<BindingId> for ::std::string::String {
fn from(value: BindingId) -> Self {
value.0
}
}
impl ::std::str::FromStr for BindingId {
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("^gb_[A-Za-z0-9_-]{16,64}$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^gb_[A-Za-z0-9_-]{16,64}$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for BindingId {
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 BindingId {
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 BindingId {
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 BindingId {
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())
})
}
}
///`BindingSpec`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "BindingSpec",
/// "oneOf": [
/// {
/// "$ref": "#/definitions/RoomBindingSpec"
/// },
/// {
/// "$ref": "#/definitions/GrantsBindingSpec"
/// },
/// {
/// "$ref": "#/definitions/RoleBindingSpec"
/// }
/// ]
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(untagged)]
#[non_exhaustive]
pub enum BindingSpec {
RoomBindingSpec(RoomBindingSpec),
GrantsBindingSpec(GrantsBindingSpec),
RoleBindingSpec(RoleBindingSpec),
}
impl ::std::convert::From<RoomBindingSpec> for BindingSpec {
fn from(value: RoomBindingSpec) -> Self {
Self::RoomBindingSpec(value)
}
}
impl ::std::convert::From<GrantsBindingSpec> for BindingSpec {
fn from(value: GrantsBindingSpec) -> Self {
Self::GrantsBindingSpec(value)
}
}
impl ::std::convert::From<RoleBindingSpec> for BindingSpec {
fn from(value: RoleBindingSpec) -> Self {
Self::RoleBindingSpec(value)
}
}
///Opaque identifier of one administrative power in the maintainer's capability registry — lowercase dot-separated segments (e.g. `keys.sign`, `vtc.roles.assign`, `git.repo.manage`). A consumer MUST NOT treat a capability it does not recognise as granted.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Capability",
/// "description": "Opaque identifier of one administrative power in the maintainer's capability registry — lowercase dot-separated segments (e.g. `keys.sign`, `vtc.roles.assign`, `git.repo.manage`). A consumer MUST NOT treat a capability it does not recognise as granted.",
/// "type": "string",
/// "maxLength": 128,
/// "minLength": 1,
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)*$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct Capability(::std::string::String);
impl ::std::ops::Deref for Capability {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<Capability> for ::std::string::String {
fn from(value: Capability) -> Self {
value.0
}
}
impl ::std::str::FromStr for Capability {
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());
}
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 Capability {
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 Capability {
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 Capability {
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 Capability {
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 capability, optionally qualified by a resource. Used where a capability is named but not granted — a role's ceiling, a role's approve ceiling, an entry's approvable capabilities. An unqualified reference covers every resource of the capability's kind.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "CapabilityRef",
/// "description": "A capability, optionally qualified by a resource. Used where a capability is named but not granted — a role's ceiling, a role's approve ceiling, an entry's approvable capabilities. An unqualified reference covers every resource of the capability's kind.",
/// "type": "object",
/// "required": [
/// "capability"
/// ],
/// "properties": {
/// "capability": {
/// "$ref": "#/definitions/Capability"
/// },
/// "resource": {
/// "description": "Optional qualifier. Absent covers every resource of the capability's kind.",
/// "$ref": "#/definitions/ResourceQualifier"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct CapabilityRef {
pub capability: Capability,
///Optional qualifier. Absent covers every resource of the capability's kind.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub resource: ::std::option::Option<ResourceQualifier>,
}
impl CapabilityRef {
pub fn builder() -> builder::CapabilityRef {
Default::default()
}
}
///Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Ext",
/// "description": "Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.",
/// "type": "object",
/// "minProperties": 1,
/// "additionalProperties": true,
/// "propertyNames": {
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
/// }
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct Ext(pub ::std::collections::HashMap<ExtKey, ::serde_json::Value>);
impl ::std::ops::Deref for Ext {
type Target = ::std::collections::HashMap<ExtKey, ::serde_json::Value>;
fn deref(&self) -> &::std::collections::HashMap<ExtKey, ::serde_json::Value> {
&self.0
}
}
impl ::std::convert::From<Ext> for ::std::collections::HashMap<ExtKey, ::serde_json::Value> {
fn from(value: Ext) -> Self {
value.0
}
}
impl ::std::convert::From<::std::collections::HashMap<ExtKey, ::serde_json::Value>> for Ext {
fn from(value: ::std::collections::HashMap<ExtKey, ::serde_json::Value>) -> Self {
Self(value)
}
}
///`ExtKey`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "pattern": "^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ExtKey(::std::string::String);
impl ::std::ops::Deref for ExtKey {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ExtKey> for ::std::string::String {
fn from(value: ExtKey) -> Self {
value.0
}
}
impl ::std::str::FromStr for ExtKey {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new("^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[a-z][a-z0-9-]*(\\.[a-z0-9-]+)+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<&::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: &::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl ::std::convert::TryFrom<::std::string::String> for ExtKey {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
impl<'de> ::serde::Deserialize<'de> for ExtKey {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///A grant set the group confers: each capability is written onto every member's access-control entry as a resource grant whose source is the group, bounded by the member's role ceiling and by the binder's own holdings.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "GrantsBindingSpec",
/// "description": "A grant set the group confers: each capability is written onto every member's access-control entry as a resource grant whose source is the group, bounded by the member's role ceiling and by the binder's own holdings.",
/// "type": "object",
/// "required": [
/// "grants",
/// "kind"
/// ],
/// "properties": {
/// "grants": {
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/CapabilityRef"
/// },
/// "maxItems": 32,
/// "minItems": 1,
/// "uniqueItems": true
/// },
/// "kind": {
/// "type": "string",
/// "const": "grants"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct GrantsBindingSpec {
pub grants: Vec<CapabilityRef>,
pub kind: ::std::string::String,
}
impl GrantsBindingSpec {
pub fn builder() -> builder::GrantsBindingSpec {
Default::default()
}
}
///`GroupBinding`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "GroupBinding",
/// "type": "object",
/// "required": [
/// "binding",
/// "bindingId",
/// "createdAt",
/// "state"
/// ],
/// "properties": {
/// "binding": {
/// "$ref": "#/definitions/BindingSpec"
/// },
/// "bindingId": {
/// "$ref": "#/definitions/BindingId"
/// },
/// "createdAt": {
/// "type": "string",
/// "format": "date-time"
/// },
/// "createdBy": {
/// "type": "string",
/// "maxLength": 2048,
/// "pattern": "^did:"
/// },
/// "state": {
/// "description": "`pending`: waiting for the consent the community requires. `active`: in force; the community's reconciler keeps members' admissions and grants in line with it. `removing`: being withdrawn; the reconciler is removing what only this binding provided.",
/// "type": "string",
/// "enum": [
/// "pending",
/// "active",
/// "removing"
/// ]
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct GroupBinding {
pub binding: BindingSpec,
#[serde(rename = "bindingId")]
pub binding_id: BindingId,
#[serde(rename = "createdAt")]
pub created_at: ::chrono::DateTime<::chrono::offset::Utc>,
#[serde(
rename = "createdBy",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub created_by: ::std::option::Option<GroupBindingCreatedBy>,
///`pending`: waiting for the consent the community requires. `active`: in force; the community's reconciler keeps members' admissions and grants in line with it. `removing`: being withdrawn; the reconciler is removing what only this binding provided.
pub state: GroupBindingState,
}
impl GroupBinding {
pub fn builder() -> builder::GroupBinding {
Default::default()
}
}
///`GroupBindingCreatedBy`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 2048,
/// "pattern": "^did:"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct GroupBindingCreatedBy(::std::string::String);
impl ::std::ops::Deref for GroupBindingCreatedBy {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<GroupBindingCreatedBy> for ::std::string::String {
fn from(value: GroupBindingCreatedBy) -> Self {
value.0
}
}
impl ::std::str::FromStr for GroupBindingCreatedBy {
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());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| ::regress::Regex::new("^did:").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^did:\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for GroupBindingCreatedBy {
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 GroupBindingCreatedBy {
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 GroupBindingCreatedBy {
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 GroupBindingCreatedBy {
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())
})
}
}
///`pending`: waiting for the consent the community requires. `active`: in force; the community's reconciler keeps members' admissions and grants in line with it. `removing`: being withdrawn; the reconciler is removing what only this binding provided.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "`pending`: waiting for the consent the community requires. `active`: in force; the community's reconciler keeps members' admissions and grants in line with it. `removing`: being withdrawn; the reconciler is removing what only this binding provided.",
/// "type": "string",
/// "enum": [
/// "pending",
/// "active",
/// "removing"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum GroupBindingState {
#[serde(rename = "pending")]
Pending,
#[serde(rename = "active")]
Active,
#[serde(rename = "removing")]
Removing,
}
impl ::std::fmt::Display for GroupBindingState {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Pending => f.write_str("pending"),
Self::Active => f.write_str("active"),
Self::Removing => f.write_str("removing"),
}
}
}
impl ::std::str::FromStr for GroupBindingState {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"pending" => Ok(Self::Pending),
"active" => Ok(Self::Active),
"removing" => Ok(Self::Removing),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for GroupBindingState {
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 GroupBindingState {
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 GroupBindingState {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Opaque identifier of a community group: `grp_` followed by 16 to 64 base64url characters. Random and community-scoped; not the group's DID.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "GroupId",
/// "description": "Opaque identifier of a community group: `grp_` followed by 16 to 64 base64url characters. Random and community-scoped; not the group's DID.",
/// "type": "string",
/// "pattern": "^grp_[A-Za-z0-9_-]{16,64}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct GroupId(::std::string::String);
impl ::std::ops::Deref for GroupId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<GroupId> for ::std::string::String {
fn from(value: GroupId) -> Self {
value.0
}
}
impl ::std::str::FromStr for GroupId {
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("^grp_[A-Za-z0-9_-]{16,64}$").unwrap()
});
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^grp_[A-Za-z0-9_-]{16,64}$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for GroupId {
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 GroupId {
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 GroupId {
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 GroupId {
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 a member of a community-owned room may do there. `admin` is not among them: minting epochs, admitting and removing members are the community's, as the room's owner, and are exercised through the vtc/rooms/community/* tasks rather than by any member's credential. `curate` is not implied by `write`.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "MemberAction",
/// "description": "What a member of a community-owned room may do there. `admin` is not among them: minting epochs, admitting and removing members are the community's, as the room's owner, and are exercised through the vtc/rooms/community/* tasks rather than by any member's credential. `curate` is not implied by `write`.",
/// "type": "string",
/// "enum": [
/// "read",
/// "write",
/// "curate"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum MemberAction {
#[serde(rename = "read")]
Read,
#[serde(rename = "write")]
Write,
#[serde(rename = "curate")]
Curate,
}
impl ::std::fmt::Display for MemberAction {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Read => f.write_str("read"),
Self::Write => f.write_str("write"),
Self::Curate => f.write_str("curate"),
}
}
}
impl ::std::str::FromStr for MemberAction {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"read" => Ok(Self::Read),
"write" => Ok(Self::Write),
"curate" => Ok(Self::Curate),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for MemberAction {
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 MemberAction {
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 MemberAction {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///The actions granted, at least one. An empty list confers nothing rather than everything, and a schema that allowed it would make the more dangerous reading available to a careless consumer.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "MemberActions",
/// "description": "The actions granted, at least one. An empty list confers nothing rather than everything, and a schema that allowed it would make the more dangerous reading available to a careless consumer.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/MemberAction"
/// },
/// "maxItems": 3,
/// "minItems": 1,
/// "uniqueItems": true
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(transparent)]
pub struct MemberActions(pub Vec<MemberAction>);
impl ::std::ops::Deref for MemberActions {
type Target = Vec<MemberAction>;
fn deref(&self) -> &Vec<MemberAction> {
&self.0
}
}
impl ::std::convert::From<MemberActions> for Vec<MemberAction> {
fn from(value: MemberActions) -> Self {
value.0
}
}
impl ::std::convert::From<Vec<MemberAction>> for MemberActions {
fn from(value: Vec<MemberAction>) -> Self {
Self(value)
}
}
///Bind a group to a community room, so its members are offered admission, or to a grant set or role's capabilities, which the community provisions into members' access-control entries with the group as their source. The outer document members are owned by the framework — SPEC §6.3.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/vtc/groups/bindings/add/0.1",
/// "title": "Payload",
/// "description": "Bind a group to a community room, so its members are offered admission, or to a grant set or role's capabilities, which the community provisions into members' access-control entries with the group as their source. The outer document members are owned by the framework — SPEC §6.3.",
/// "type": "object",
/// "required": [
/// "binding",
/// "groupId",
/// "reason"
/// ],
/// "properties": {
/// "binding": {
/// "$ref": "#/definitions/BindingSpec"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "groupId": {
/// "$ref": "#/definitions/GroupId"
/// },
/// "reason": {
/// "description": "Why, recorded with the change and shown to anyone who must approve it.",
/// "type": "string",
/// "maxLength": 1024,
/// "minLength": 1
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
pub binding: BindingSpec,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
#[serde(rename = "groupId")]
pub group_id: GroupId,
///Why, recorded with the change and shown to anyone who must approve it.
pub reason: PayloadReason,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///Why, recorded with the change and shown to anyone who must approve it.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Why, recorded with the change and shown to anyone who must approve it.",
/// "type": "string",
/// "maxLength": 1024,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadReason(::std::string::String);
impl ::std::ops::Deref for PayloadReason {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadReason> for ::std::string::String {
fn from(value: PayloadReason) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadReason {
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());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadReason {
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 PayloadReason {
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 PayloadReason {
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 PayloadReason {
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())
})
}
}
///Opaque qualifier naming the part of the maintainer's resources a capability applies to (e.g. `git-ns:github.com/acme`, `git-repo:github.com/acme/r#4211`, `policy:join`). Its grammar and containment rule are the maintainer's: a qualified capability covers the named resource and the resources inside it. A qualifier MUST NOT be read as widening the entry's act scope.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ResourceQualifier",
/// "description": "Opaque qualifier naming the part of the maintainer's resources a capability applies to (e.g. `git-ns:github.com/acme`, `git-repo:github.com/acme/r#4211`, `policy:join`). Its grammar and containment rule are the maintainer's: a qualified capability covers the named resource and the resources inside it. A qualifier MUST NOT be read as widening the entry's act scope.",
/// "type": "string",
/// "maxLength": 512,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResourceQualifier(::std::string::String);
impl ::std::ops::Deref for ResourceQualifier {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResourceQualifier> for ::std::string::String {
fn from(value: ResourceQualifier) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResourceQualifier {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 512usize {
return Err("longer than 512 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ResourceQualifier {
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 ResourceQualifier {
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 ResourceQualifier {
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 ResourceQualifier {
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 success response to a vtc/groups/bindings/add/0.1 request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/vtc/groups/bindings/add/0.1#response.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "The success response to a vtc/groups/bindings/add/0.1 request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/vtc/groups/bindings/add/0.1#response.",
/// "type": "object",
/// "required": [
/// "binding"
/// ],
/// "properties": {
/// "binding": {
/// "$ref": "#/definitions/GroupBinding"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
pub binding: GroupBinding,
#[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()
}
}
///A grant set by reference: the capability ceiling of a defined role, conferred as resource grants exactly as a `grants` binding confers its list. It never assigns the role itself — an entry's administrative role and its community role stay direct assignments.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "RoleBindingSpec",
/// "description": "A grant set by reference: the capability ceiling of a defined role, conferred as resource grants exactly as a `grants` binding confers its list. It never assigns the role itself — an entry's administrative role and its community role stay direct assignments.",
/// "type": "object",
/// "required": [
/// "kind",
/// "role"
/// ],
/// "properties": {
/// "kind": {
/// "type": "string",
/// "const": "role"
/// },
/// "role": {
/// "$ref": "#/definitions/RoleName"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct RoleBindingSpec {
pub kind: ::std::string::String,
pub role: RoleName,
}
impl RoleBindingSpec {
pub fn builder() -> builder::RoleBindingSpec {
Default::default()
}
}
///A role identifier: lowercase, hyphen-separated, at most 64 characters. Compared by exact string equality. It is the value an AclEntry 0.2 carries in `role`.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "RoleName",
/// "description": "A role identifier: lowercase, hyphen-separated, at most 64 characters. Compared by exact string equality. It is the value an AclEntry 0.2 carries in `role`.",
/// "type": "string",
/// "pattern": "^[a-z][a-z0-9-]{0,63}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct RoleName(::std::string::String);
impl ::std::ops::Deref for RoleName {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<RoleName> for ::std::string::String {
fn from(value: RoleName) -> Self {
value.0
}
}
impl ::std::str::FromStr for RoleName {
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-]{0,63}$").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[a-z][a-z0-9-]{0,63}$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for RoleName {
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 RoleName {
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 RoleName {
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 RoleName {
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())
})
}
}
///Links a room the community owns to the group: joining the group offers the member admission to the room with `actions`, valid for `validFor`, renewed while they stay in the group (collected with vtc/rooms/offers/list at 0.3 or later); leaving removes them unless another source still covers them.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "RoomBindingSpec",
/// "description": "Links a room the community owns to the group: joining the group offers the member admission to the room with `actions`, valid for `validFor`, renewed while they stay in the group (collected with vtc/rooms/offers/list at 0.3 or later); leaving removes them unless another source still covers them.",
/// "type": "object",
/// "required": [
/// "actions",
/// "kind",
/// "roomId",
/// "validFor"
/// ],
/// "properties": {
/// "actions": {
/// "$ref": "#/definitions/MemberActions"
/// },
/// "kind": {
/// "type": "string",
/// "const": "room"
/// },
/// "roomId": {
/// "description": "The community-owned room's DID.",
/// "type": "string",
/// "maxLength": 512,
/// "pattern": "^did:"
/// },
/// "validFor": {
/// "description": "How long each admission's authority runs, as an ISO 8601 duration in whole days (`P365D`). The community renews it while the member stays in the group.",
/// "type": "string",
/// "pattern": "^P[1-9][0-9]{0,4}D$"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct RoomBindingSpec {
pub actions: MemberActions,
pub kind: ::std::string::String,
///The community-owned room's DID.
#[serde(rename = "roomId")]
pub room_id: RoomBindingSpecRoomId,
///How long each admission's authority runs, as an ISO 8601 duration in whole days (`P365D`). The community renews it while the member stays in the group.
#[serde(rename = "validFor")]
pub valid_for: RoomBindingSpecValidFor,
}
impl RoomBindingSpec {
pub fn builder() -> builder::RoomBindingSpec {
Default::default()
}
}
///The community-owned room's DID.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The community-owned room's DID.",
/// "type": "string",
/// "maxLength": 512,
/// "pattern": "^did:"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct RoomBindingSpecRoomId(::std::string::String);
impl ::std::ops::Deref for RoomBindingSpecRoomId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<RoomBindingSpecRoomId> for ::std::string::String {
fn from(value: RoomBindingSpecRoomId) -> Self {
value.0
}
}
impl ::std::str::FromStr for RoomBindingSpecRoomId {
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());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| ::regress::Regex::new("^did:").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^did:\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for RoomBindingSpecRoomId {
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 RoomBindingSpecRoomId {
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 RoomBindingSpecRoomId {
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 RoomBindingSpecRoomId {
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())
})
}
}
///How long each admission's authority runs, as an ISO 8601 duration in whole days (`P365D`). The community renews it while the member stays in the group.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "How long each admission's authority runs, as an ISO 8601 duration in whole days (`P365D`). The community renews it while the member stays in the group.",
/// "type": "string",
/// "pattern": "^P[1-9][0-9]{0,4}D$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct RoomBindingSpecValidFor(::std::string::String);
impl ::std::ops::Deref for RoomBindingSpecValidFor {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<RoomBindingSpecValidFor> for ::std::string::String {
fn from(value: RoomBindingSpecValidFor) -> Self {
value.0
}
}
impl ::std::str::FromStr for RoomBindingSpecValidFor {
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("^P[1-9][0-9]{0,4}D$").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^P[1-9][0-9]{0,4}D$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for RoomBindingSpecValidFor {
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 RoomBindingSpecValidFor {
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 RoomBindingSpecValidFor {
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 RoomBindingSpecValidFor {
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 CapabilityRef {
capability: ::std::result::Result<super::Capability, ::std::string::String>,
resource: ::std::result::Result<
::std::option::Option<super::ResourceQualifier>,
::std::string::String,
>,
}
impl ::std::default::Default for CapabilityRef {
fn default() -> Self {
Self {
capability: Err("no value supplied for capability".to_string()),
resource: Ok(Default::default()),
}
}
}
impl CapabilityRef {
pub fn capability<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Capability>,
T::Error: ::std::fmt::Display,
{
self.capability = value
.try_into()
.map_err(|e| format!("error converting supplied value for capability: {e}"));
self
}
pub fn resource<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ResourceQualifier>>,
T::Error: ::std::fmt::Display,
{
self.resource = value
.try_into()
.map_err(|e| format!("error converting supplied value for resource: {e}"));
self
}
}
impl ::std::convert::TryFrom<CapabilityRef> for super::CapabilityRef {
type Error = super::error::ConversionError;
fn try_from(
value: CapabilityRef,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
capability: value.capability?,
resource: value.resource?,
})
}
}
impl ::std::convert::From<super::CapabilityRef> for CapabilityRef {
fn from(value: super::CapabilityRef) -> Self {
Self {
capability: Ok(value.capability),
resource: Ok(value.resource),
}
}
}
#[derive(Clone, Debug)]
pub struct GrantsBindingSpec {
grants: ::std::result::Result<Vec<super::CapabilityRef>, ::std::string::String>,
kind: ::std::result::Result<::std::string::String, ::std::string::String>,
}
impl ::std::default::Default for GrantsBindingSpec {
fn default() -> Self {
Self {
grants: Err("no value supplied for grants".to_string()),
kind: Err("no value supplied for kind".to_string()),
}
}
}
impl GrantsBindingSpec {
pub fn grants<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<Vec<super::CapabilityRef>>,
T::Error: ::std::fmt::Display,
{
self.grants = value
.try_into()
.map_err(|e| format!("error converting supplied value for grants: {e}"));
self
}
pub fn kind<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.kind = value
.try_into()
.map_err(|e| format!("error converting supplied value for kind: {e}"));
self
}
}
impl ::std::convert::TryFrom<GrantsBindingSpec> for super::GrantsBindingSpec {
type Error = super::error::ConversionError;
fn try_from(
value: GrantsBindingSpec,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
grants: value.grants?,
kind: value.kind?,
})
}
}
impl ::std::convert::From<super::GrantsBindingSpec> for GrantsBindingSpec {
fn from(value: super::GrantsBindingSpec) -> Self {
Self {
grants: Ok(value.grants),
kind: Ok(value.kind),
}
}
}
#[derive(Clone, Debug)]
pub struct GroupBinding {
binding: ::std::result::Result<super::BindingSpec, ::std::string::String>,
binding_id: ::std::result::Result<super::BindingId, ::std::string::String>,
created_at:
::std::result::Result<::chrono::DateTime<::chrono::offset::Utc>, ::std::string::String>,
created_by: ::std::result::Result<
::std::option::Option<super::GroupBindingCreatedBy>,
::std::string::String,
>,
state: ::std::result::Result<super::GroupBindingState, ::std::string::String>,
}
impl ::std::default::Default for GroupBinding {
fn default() -> Self {
Self {
binding: Err("no value supplied for binding".to_string()),
binding_id: Err("no value supplied for binding_id".to_string()),
created_at: Err("no value supplied for created_at".to_string()),
created_by: Ok(Default::default()),
state: Err("no value supplied for state".to_string()),
}
}
}
impl GroupBinding {
pub fn binding<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::BindingSpec>,
T::Error: ::std::fmt::Display,
{
self.binding = value
.try_into()
.map_err(|e| format!("error converting supplied value for binding: {e}"));
self
}
pub fn binding_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::BindingId>,
T::Error: ::std::fmt::Display,
{
self.binding_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for binding_id: {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 created_by<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::GroupBindingCreatedBy>>,
T::Error: ::std::fmt::Display,
{
self.created_by = value
.try_into()
.map_err(|e| format!("error converting supplied value for created_by: {e}"));
self
}
pub fn state<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::GroupBindingState>,
T::Error: ::std::fmt::Display,
{
self.state = value
.try_into()
.map_err(|e| format!("error converting supplied value for state: {e}"));
self
}
}
impl ::std::convert::TryFrom<GroupBinding> for super::GroupBinding {
type Error = super::error::ConversionError;
fn try_from(
value: GroupBinding,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
binding: value.binding?,
binding_id: value.binding_id?,
created_at: value.created_at?,
created_by: value.created_by?,
state: value.state?,
})
}
}
impl ::std::convert::From<super::GroupBinding> for GroupBinding {
fn from(value: super::GroupBinding) -> Self {
Self {
binding: Ok(value.binding),
binding_id: Ok(value.binding_id),
created_at: Ok(value.created_at),
created_by: Ok(value.created_by),
state: Ok(value.state),
}
}
}
#[derive(Clone, Debug)]
pub struct Payload {
binding: ::std::result::Result<super::BindingSpec, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
group_id: ::std::result::Result<super::GroupId, ::std::string::String>,
reason: ::std::result::Result<super::PayloadReason, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
binding: Err("no value supplied for binding".to_string()),
ext: Ok(Default::default()),
group_id: Err("no value supplied for group_id".to_string()),
reason: Err("no value supplied for reason".to_string()),
}
}
}
impl Payload {
pub fn binding<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::BindingSpec>,
T::Error: ::std::fmt::Display,
{
self.binding = value
.try_into()
.map_err(|e| format!("error converting supplied value for binding: {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 group_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::GroupId>,
T::Error: ::std::fmt::Display,
{
self.group_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for group_id: {e}"));
self
}
pub fn reason<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadReason>,
T::Error: ::std::fmt::Display,
{
self.reason = value
.try_into()
.map_err(|e| format!("error converting supplied value for reason: {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 {
binding: value.binding?,
ext: value.ext?,
group_id: value.group_id?,
reason: value.reason?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
binding: Ok(value.binding),
ext: Ok(value.ext),
group_id: Ok(value.group_id),
reason: Ok(value.reason),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
binding: ::std::result::Result<super::GroupBinding, ::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 {
binding: Err("no value supplied for binding".to_string()),
ext: Ok(Default::default()),
}
}
}
impl Response {
pub fn binding<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::GroupBinding>,
T::Error: ::std::fmt::Display,
{
self.binding = value
.try_into()
.map_err(|e| format!("error converting supplied value for binding: {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 {
binding: value.binding?,
ext: value.ext?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
binding: Ok(value.binding),
ext: Ok(value.ext),
}
}
}
#[derive(Clone, Debug)]
pub struct RoleBindingSpec {
kind: ::std::result::Result<::std::string::String, ::std::string::String>,
role: ::std::result::Result<super::RoleName, ::std::string::String>,
}
impl ::std::default::Default for RoleBindingSpec {
fn default() -> Self {
Self {
kind: Err("no value supplied for kind".to_string()),
role: Err("no value supplied for role".to_string()),
}
}
}
impl RoleBindingSpec {
pub fn kind<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.kind = value
.try_into()
.map_err(|e| format!("error converting supplied value for kind: {e}"));
self
}
pub fn role<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::RoleName>,
T::Error: ::std::fmt::Display,
{
self.role = value
.try_into()
.map_err(|e| format!("error converting supplied value for role: {e}"));
self
}
}
impl ::std::convert::TryFrom<RoleBindingSpec> for super::RoleBindingSpec {
type Error = super::error::ConversionError;
fn try_from(
value: RoleBindingSpec,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
kind: value.kind?,
role: value.role?,
})
}
}
impl ::std::convert::From<super::RoleBindingSpec> for RoleBindingSpec {
fn from(value: super::RoleBindingSpec) -> Self {
Self {
kind: Ok(value.kind),
role: Ok(value.role),
}
}
}
#[derive(Clone, Debug)]
pub struct RoomBindingSpec {
actions: ::std::result::Result<super::MemberActions, ::std::string::String>,
kind: ::std::result::Result<::std::string::String, ::std::string::String>,
room_id: ::std::result::Result<super::RoomBindingSpecRoomId, ::std::string::String>,
valid_for: ::std::result::Result<super::RoomBindingSpecValidFor, ::std::string::String>,
}
impl ::std::default::Default for RoomBindingSpec {
fn default() -> Self {
Self {
actions: Err("no value supplied for actions".to_string()),
kind: Err("no value supplied for kind".to_string()),
room_id: Err("no value supplied for room_id".to_string()),
valid_for: Err("no value supplied for valid_for".to_string()),
}
}
}
impl RoomBindingSpec {
pub fn actions<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::MemberActions>,
T::Error: ::std::fmt::Display,
{
self.actions = value
.try_into()
.map_err(|e| format!("error converting supplied value for actions: {e}"));
self
}
pub fn kind<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.kind = value
.try_into()
.map_err(|e| format!("error converting supplied value for kind: {e}"));
self
}
pub fn room_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::RoomBindingSpecRoomId>,
T::Error: ::std::fmt::Display,
{
self.room_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for room_id: {e}"));
self
}
pub fn valid_for<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::RoomBindingSpecValidFor>,
T::Error: ::std::fmt::Display,
{
self.valid_for = value
.try_into()
.map_err(|e| format!("error converting supplied value for valid_for: {e}"));
self
}
}
impl ::std::convert::TryFrom<RoomBindingSpec> for super::RoomBindingSpec {
type Error = super::error::ConversionError;
fn try_from(
value: RoomBindingSpec,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
actions: value.actions?,
kind: value.kind?,
room_id: value.room_id?,
valid_for: value.valid_for?,
})
}
}
impl ::std::convert::From<super::RoomBindingSpec> for RoomBindingSpec {
fn from(value: super::RoomBindingSpec) -> Self {
Self {
actions: Ok(value.actions),
kind: Ok(value.kind),
room_id: Ok(value.room_id),
valid_for: Ok(value.valid_for),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/vtc/groups/bindings/add/0.1";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"BindingId\": {\n \"pattern\": \"^gb_[A-Za-z0-9_-]{16,64}$\",\n \"title\": \"BindingId\",\n \"type\": \"string\"\n },\n \"BindingSpec\": {\n \"oneOf\": [\n {\n \"$ref\": \"#/$defs/RoomBindingSpec\"\n },\n {\n \"$ref\": \"#/$defs/GrantsBindingSpec\"\n },\n {\n \"$ref\": \"#/$defs/RoleBindingSpec\"\n }\n ],\n \"title\": \"BindingSpec\"\n },\n \"Capability\": {\n \"description\": \"Opaque identifier of one administrative power in the maintainer's capability registry — lowercase dot-separated segments (e.g. `keys.sign`, `vtc.roles.assign`, `git.repo.manage`). A consumer MUST NOT treat a capability it does not recognise as granted.\",\n \"maxLength\": 128,\n \"minLength\": 1,\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)*$\",\n \"title\": \"Capability\",\n \"type\": \"string\"\n },\n \"CapabilityRef\": {\n \"additionalProperties\": false,\n \"description\": \"A capability, optionally qualified by a resource. Used where a capability is named but not granted — a role's ceiling, a role's approve ceiling, an entry's approvable capabilities. An unqualified reference covers every resource of the capability's kind.\",\n \"properties\": {\n \"capability\": {\n \"$ref\": \"#/$defs/Capability\"\n },\n \"resource\": {\n \"$ref\": \"#/$defs/ResourceQualifier\",\n \"description\": \"Optional qualifier. Absent covers every resource of the capability's kind.\"\n }\n },\n \"required\": [\n \"capability\"\n ],\n \"title\": \"CapabilityRef\",\n \"type\": \"object\"\n },\n \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"GrantsBindingSpec\": {\n \"additionalProperties\": false,\n \"description\": \"A grant set the group confers: each capability is written onto every member's access-control entry as a resource grant whose source is the group, bounded by the member's role ceiling and by the binder's own holdings.\",\n \"properties\": {\n \"grants\": {\n \"items\": {\n \"$ref\": \"#/$defs/CapabilityRef\"\n },\n \"maxItems\": 32,\n \"minItems\": 1,\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"kind\": {\n \"const\": \"grants\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"kind\",\n \"grants\"\n ],\n \"title\": \"GrantsBindingSpec\",\n \"type\": \"object\"\n },\n \"GroupBinding\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"binding\": {\n \"$ref\": \"#/$defs/BindingSpec\"\n },\n \"bindingId\": {\n \"$ref\": \"#/$defs/BindingId\"\n },\n \"createdAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"createdBy\": {\n \"maxLength\": 2048,\n \"pattern\": \"^did:\",\n \"type\": \"string\"\n },\n \"state\": {\n \"description\": \"`pending`: waiting for the consent the community requires. `active`: in force; the community's reconciler keeps members' admissions and grants in line with it. `removing`: being withdrawn; the reconciler is removing what only this binding provided.\",\n \"enum\": [\n \"pending\",\n \"active\",\n \"removing\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"bindingId\",\n \"binding\",\n \"state\",\n \"createdAt\"\n ],\n \"title\": \"GroupBinding\",\n \"type\": \"object\"\n },\n \"GroupId\": {\n \"description\": \"Opaque identifier of a community group: `grp_` followed by 16 to 64 base64url characters. Random and community-scoped; not the group's DID.\",\n \"pattern\": \"^grp_[A-Za-z0-9_-]{16,64}$\",\n \"title\": \"GroupId\",\n \"type\": \"string\"\n },\n \"MemberAction\": {\n \"description\": \"What a member of a community-owned room may do there. `admin` is not among them: minting epochs, admitting and removing members are the community's, as the room's owner, and are exercised through the vtc/rooms/community/* tasks rather than by any member's credential. `curate` is not implied by `write`.\",\n \"enum\": [\n \"read\",\n \"write\",\n \"curate\"\n ],\n \"title\": \"MemberAction\",\n \"type\": \"string\"\n },\n \"MemberActions\": {\n \"description\": \"The actions granted, at least one. An empty list confers nothing rather than everything, and a schema that allowed it would make the more dangerous reading available to a careless consumer.\",\n \"items\": {\n \"$ref\": \"#/$defs/MemberAction\"\n },\n \"maxItems\": 3,\n \"minItems\": 1,\n \"title\": \"MemberActions\",\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"ResourceQualifier\": {\n \"description\": \"Opaque qualifier naming the part of the maintainer's resources a capability applies to (e.g. `git-ns:github.com/acme`, `git-repo:github.com/acme/r#4211`, `policy:join`). Its grammar and containment rule are the maintainer's: a qualified capability covers the named resource and the resources inside it. A qualifier MUST NOT be read as widening the entry's act scope.\",\n \"maxLength\": 512,\n \"minLength\": 1,\n \"title\": \"ResourceQualifier\",\n \"type\": \"string\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"The success response to a vtc/groups/bindings/add/0.1 request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/vtc/groups/bindings/add/0.1#response.\",\n \"properties\": {\n \"binding\": {\n \"$ref\": \"#/$defs/GroupBinding\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n }\n },\n \"required\": [\n \"binding\"\n ],\n \"title\": \"VTC Groups — Bindings — Add — response payload\",\n \"type\": \"object\"\n },\n \"RoleBindingSpec\": {\n \"additionalProperties\": false,\n \"description\": \"A grant set by reference: the capability ceiling of a defined role, conferred as resource grants exactly as a `grants` binding confers its list. It never assigns the role itself — an entry's administrative role and its community role stay direct assignments.\",\n \"properties\": {\n \"kind\": {\n \"const\": \"role\",\n \"type\": \"string\"\n },\n \"role\": {\n \"$ref\": \"#/$defs/RoleName\"\n }\n },\n \"required\": [\n \"kind\",\n \"role\"\n ],\n \"title\": \"RoleBindingSpec\",\n \"type\": \"object\"\n },\n \"RoleName\": {\n \"description\": \"A role identifier: lowercase, hyphen-separated, at most 64 characters. Compared by exact string equality. It is the value an AclEntry 0.2 carries in `role`.\",\n \"pattern\": \"^[a-z][a-z0-9-]{0,63}$\",\n \"title\": \"RoleName\",\n \"type\": \"string\"\n },\n \"RoomBindingSpec\": {\n \"additionalProperties\": false,\n \"description\": \"Links a room the community owns to the group: joining the group offers the member admission to the room with `actions`, valid for `validFor`, renewed while they stay in the group (collected with vtc/rooms/offers/list at 0.3 or later); leaving removes them unless another source still covers them.\",\n \"properties\": {\n \"actions\": {\n \"$ref\": \"#/$defs/MemberActions\"\n },\n \"kind\": {\n \"const\": \"room\",\n \"type\": \"string\"\n },\n \"roomId\": {\n \"description\": \"The community-owned room's DID.\",\n \"maxLength\": 512,\n \"pattern\": \"^did:\",\n \"type\": \"string\"\n },\n \"validFor\": {\n \"description\": \"How long each admission's authority runs, as an ISO 8601 duration in whole days (`P365D`). The community renews it while the member stays in the group.\",\n \"pattern\": \"^P[1-9][0-9]{0,4}D$\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"kind\",\n \"roomId\",\n \"actions\",\n \"validFor\"\n ],\n \"title\": \"RoomBindingSpec\",\n \"type\": \"object\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/vtc/groups/bindings/add/0.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"Bind a group to a community room, so its members are offered admission, or to a grant set or role's capabilities, which the community provisions into members' access-control entries with the group as their source. The outer document members are owned by the framework — SPEC §6.3.\",\n \"properties\": {\n \"binding\": {\n \"$ref\": \"#/$defs/BindingSpec\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"groupId\": {\n \"$ref\": \"#/$defs/GroupId\"\n },\n \"reason\": {\n \"description\": \"Why, recorded with the change and shown to anyone who must approve it.\",\n \"maxLength\": 1024,\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"groupId\",\n \"binding\",\n \"reason\"\n ],\n \"title\": \"VTC Groups — Bindings — Add — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str =
"https://trusttasks.org/spec/vtc/groups/bindings/add/0.1#response";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"BindingId\": {\n \"pattern\": \"^gb_[A-Za-z0-9_-]{16,64}$\",\n \"title\": \"BindingId\",\n \"type\": \"string\"\n },\n \"BindingSpec\": {\n \"oneOf\": [\n {\n \"$ref\": \"#/$defs/RoomBindingSpec\"\n },\n {\n \"$ref\": \"#/$defs/GrantsBindingSpec\"\n },\n {\n \"$ref\": \"#/$defs/RoleBindingSpec\"\n }\n ],\n \"title\": \"BindingSpec\"\n },\n \"Capability\": {\n \"description\": \"Opaque identifier of one administrative power in the maintainer's capability registry — lowercase dot-separated segments (e.g. `keys.sign`, `vtc.roles.assign`, `git.repo.manage`). A consumer MUST NOT treat a capability it does not recognise as granted.\",\n \"maxLength\": 128,\n \"minLength\": 1,\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)*$\",\n \"title\": \"Capability\",\n \"type\": \"string\"\n },\n \"CapabilityRef\": {\n \"additionalProperties\": false,\n \"description\": \"A capability, optionally qualified by a resource. Used where a capability is named but not granted — a role's ceiling, a role's approve ceiling, an entry's approvable capabilities. An unqualified reference covers every resource of the capability's kind.\",\n \"properties\": {\n \"capability\": {\n \"$ref\": \"#/$defs/Capability\"\n },\n \"resource\": {\n \"$ref\": \"#/$defs/ResourceQualifier\",\n \"description\": \"Optional qualifier. Absent covers every resource of the capability's kind.\"\n }\n },\n \"required\": [\n \"capability\"\n ],\n \"title\": \"CapabilityRef\",\n \"type\": \"object\"\n },\n \"Ext\": {\n \"additionalProperties\": true,\n \"description\": \"Vendor-namespaced extension object per SPEC.md §4.5.1. Each immediate key MUST be a reverse-DNS namespace; structure under each namespace is opaque to the framework.\",\n \"minProperties\": 1,\n \"propertyNames\": {\n \"pattern\": \"^[a-z][a-z0-9-]*(\\\\.[a-z0-9-]+)+$\"\n },\n \"title\": \"Ext\",\n \"type\": \"object\"\n },\n \"GrantsBindingSpec\": {\n \"additionalProperties\": false,\n \"description\": \"A grant set the group confers: each capability is written onto every member's access-control entry as a resource grant whose source is the group, bounded by the member's role ceiling and by the binder's own holdings.\",\n \"properties\": {\n \"grants\": {\n \"items\": {\n \"$ref\": \"#/$defs/CapabilityRef\"\n },\n \"maxItems\": 32,\n \"minItems\": 1,\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"kind\": {\n \"const\": \"grants\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"kind\",\n \"grants\"\n ],\n \"title\": \"GrantsBindingSpec\",\n \"type\": \"object\"\n },\n \"GroupBinding\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"binding\": {\n \"$ref\": \"#/$defs/BindingSpec\"\n },\n \"bindingId\": {\n \"$ref\": \"#/$defs/BindingId\"\n },\n \"createdAt\": {\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"createdBy\": {\n \"maxLength\": 2048,\n \"pattern\": \"^did:\",\n \"type\": \"string\"\n },\n \"state\": {\n \"description\": \"`pending`: waiting for the consent the community requires. `active`: in force; the community's reconciler keeps members' admissions and grants in line with it. `removing`: being withdrawn; the reconciler is removing what only this binding provided.\",\n \"enum\": [\n \"pending\",\n \"active\",\n \"removing\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"bindingId\",\n \"binding\",\n \"state\",\n \"createdAt\"\n ],\n \"title\": \"GroupBinding\",\n \"type\": \"object\"\n },\n \"GroupId\": {\n \"description\": \"Opaque identifier of a community group: `grp_` followed by 16 to 64 base64url characters. Random and community-scoped; not the group's DID.\",\n \"pattern\": \"^grp_[A-Za-z0-9_-]{16,64}$\",\n \"title\": \"GroupId\",\n \"type\": \"string\"\n },\n \"MemberAction\": {\n \"description\": \"What a member of a community-owned room may do there. `admin` is not among them: minting epochs, admitting and removing members are the community's, as the room's owner, and are exercised through the vtc/rooms/community/* tasks rather than by any member's credential. `curate` is not implied by `write`.\",\n \"enum\": [\n \"read\",\n \"write\",\n \"curate\"\n ],\n \"title\": \"MemberAction\",\n \"type\": \"string\"\n },\n \"MemberActions\": {\n \"description\": \"The actions granted, at least one. An empty list confers nothing rather than everything, and a schema that allowed it would make the more dangerous reading available to a careless consumer.\",\n \"items\": {\n \"$ref\": \"#/$defs/MemberAction\"\n },\n \"maxItems\": 3,\n \"minItems\": 1,\n \"title\": \"MemberActions\",\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"ResourceQualifier\": {\n \"description\": \"Opaque qualifier naming the part of the maintainer's resources a capability applies to (e.g. `git-ns:github.com/acme`, `git-repo:github.com/acme/r#4211`, `policy:join`). Its grammar and containment rule are the maintainer's: a qualified capability covers the named resource and the resources inside it. A qualifier MUST NOT be read as widening the entry's act scope.\",\n \"maxLength\": 512,\n \"minLength\": 1,\n \"title\": \"ResourceQualifier\",\n \"type\": \"string\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"The success response to a vtc/groups/bindings/add/0.1 request. Carried in a Trust Task document whose type is https://trusttasks.org/spec/vtc/groups/bindings/add/0.1#response.\",\n \"properties\": {\n \"binding\": {\n \"$ref\": \"#/$defs/GroupBinding\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n }\n },\n \"required\": [\n \"binding\"\n ],\n \"title\": \"VTC Groups — Bindings — Add — response payload\",\n \"type\": \"object\"\n },\n \"RoleBindingSpec\": {\n \"additionalProperties\": false,\n \"description\": \"A grant set by reference: the capability ceiling of a defined role, conferred as resource grants exactly as a `grants` binding confers its list. It never assigns the role itself — an entry's administrative role and its community role stay direct assignments.\",\n \"properties\": {\n \"kind\": {\n \"const\": \"role\",\n \"type\": \"string\"\n },\n \"role\": {\n \"$ref\": \"#/$defs/RoleName\"\n }\n },\n \"required\": [\n \"kind\",\n \"role\"\n ],\n \"title\": \"RoleBindingSpec\",\n \"type\": \"object\"\n },\n \"RoleName\": {\n \"description\": \"A role identifier: lowercase, hyphen-separated, at most 64 characters. Compared by exact string equality. It is the value an AclEntry 0.2 carries in `role`.\",\n \"pattern\": \"^[a-z][a-z0-9-]{0,63}$\",\n \"title\": \"RoleName\",\n \"type\": \"string\"\n },\n \"RoomBindingSpec\": {\n \"additionalProperties\": false,\n \"description\": \"Links a room the community owns to the group: joining the group offers the member admission to the room with `actions`, valid for `validFor`, renewed while they stay in the group (collected with vtc/rooms/offers/list at 0.3 or later); leaving removes them unless another source still covers them.\",\n \"properties\": {\n \"actions\": {\n \"$ref\": \"#/$defs/MemberActions\"\n },\n \"kind\": {\n \"const\": \"room\",\n \"type\": \"string\"\n },\n \"roomId\": {\n \"description\": \"The community-owned room's DID.\",\n \"maxLength\": 512,\n \"pattern\": \"^did:\",\n \"type\": \"string\"\n },\n \"validFor\": {\n \"description\": \"How long each admission's authority runs, as an ISO 8601 duration in whole days (`P365D`). The community renews it while the member stays in the group.\",\n \"pattern\": \"^P[1-9][0-9]{0,4}D$\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"kind\",\n \"roomId\",\n \"actions\",\n \"validFor\"\n ],\n \"title\": \"RoomBindingSpec\",\n \"type\": \"object\"\n }\n },\n \"$ref\": \"#/$defs/Response\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\"\n}\n",
);
}
impl crate::RequestPayload for Payload {
type Response = Response;
}
/// The extended error codes this specification declares (SPEC §7.3 item 9,
/// §8.5), in declaration order. Empty when it declares none.
pub const ERROR_CODES: &[crate::DeclaredErrorCode] = &[
error_codes::NOT_FOUND,
error_codes::ROOM_NOT_FOUND,
error_codes::GROUP_NOT_ELIGIBLE,
error_codes::UNKNOWN_CAPABILITY,
error_codes::UNKNOWN_ROLE,
error_codes::EXCEEDS_BINDER_AUTHORITY,
error_codes::BINDING_EXISTS,
error_codes::TOO_MANY_BINDINGS,
error_codes::KIND_NOT_SERVED,
];
/// One constant per extended error code this specification declares
/// (SPEC §7.3 item 9), named for its local part.
///
/// Emit these rather than a string literal: the code is read from the
/// specification, so it cannot name a code the specification never
/// declared.
pub mod error_codes {
/// `vtc/groups/bindings/add:notFound`
///
/// No group the caller may manage has this identifier.
///
/// Declared `retryable: false`.
pub const NOT_FOUND: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vtc/groups/bindings/add:notFound",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vtc/groups/bindings/add:roomNotFound`
///
/// The community owns no room with this identifier, or the caller does not hold `vtc.rooms.manage` for it.
///
/// Declared `retryable: false`.
pub const ROOM_NOT_FOUND: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vtc/groups/bindings/add:roomNotFound",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vtc/groups/bindings/add:groupNotEligible`
///
/// A grants or role binding was sent for a dynamic group or one whose `joinPolicy` is not `closed`.
///
/// Declared `retryable: false`.
pub const GROUP_NOT_ELIGIBLE: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vtc/groups/bindings/add:groupNotEligible",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vtc/groups/bindings/add:unknownCapability`
///
/// A capability is not in the community's capability registry.
///
/// Declared `retryable: false`.
/// Declares a `detailsSchema` for the error's `details` member.
pub const UNKNOWN_CAPABILITY: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vtc/groups/bindings/add:unknownCapability",
retryable: false,
details_schema: ::core::option::Option::Some(
"{\"additionalProperties\":false,\"properties\":{\"capabilities\":{\"items\":{\"maxLength\":128,\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\"}},\"required\":[\"capabilities\"],\"type\":\"object\"}",
),
};
/// `vtc/groups/bindings/add:unknownRole`
///
/// No role of this name is defined.
///
/// Declared `retryable: false`.
pub const UNKNOWN_ROLE: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vtc/groups/bindings/add:unknownRole",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vtc/groups/bindings/add:exceedsBinderAuthority`
///
/// A capability is not held, at a qualifier at least as wide, by the administrators whose authority makes the binding.
///
/// Declared `retryable: false`.
/// Declares a `detailsSchema` for the error's `details` member.
pub const EXCEEDS_BINDER_AUTHORITY: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vtc/groups/bindings/add:exceedsBinderAuthority",
retryable: false,
details_schema: ::core::option::Option::Some(
"{\"additionalProperties\":false,\"properties\":{\"capabilities\":{\"items\":{\"maxLength\":128,\"type\":\"string\"},\"maxItems\":32,\"type\":\"array\"}},\"required\":[\"capabilities\"],\"type\":\"object\"}",
),
};
/// `vtc/groups/bindings/add:bindingExists`
///
/// An equal binding already exists.
///
/// Declared `retryable: false`.
pub const BINDING_EXISTS: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vtc/groups/bindings/add:bindingExists",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vtc/groups/bindings/add:tooManyBindings`
///
/// The group already has 64 bindings.
///
/// Declared `retryable: false`.
pub const TOO_MANY_BINDINGS: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vtc/groups/bindings/add:tooManyBindings",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `vtc/groups/bindings/add:kindNotServed`
///
/// The community serves room bindings only. A grants or role binding is not recorded; nothing was stored.
///
/// Declared `retryable: false`.
pub const KIND_NOT_SERVED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "vtc/groups/bindings/add:kindNotServed",
retryable: false,
details_schema: ::core::option::Option::None,
};
}