//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `rooms/usage`. 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())
}
}
}
///What a party presents to act on a room. Carries the whole authority chain: a host MUST NOT dereference an authority credential's `parent` to fetch a link it was not given. Resolving over the network would make verification depend on availability, turn every identifier into a request the host can be induced to make against an address the holder chooses, and signal credential use to whoever hosts the identifier. A host MUST bind the presenter to the chain's leaf. A chain that verifies is evidence that authority was conferred on somebody; it is not evidence that the party presenting it is that somebody. The leaf's subject MUST equal the party the host authenticated for this request — an identity the transport established or a document `proof` proved, never one named in a payload. A host that omits this check authorizes every captured presentation, and the omission is silent, because the chain still verifies.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "AuthorityPresentation",
/// "description": "What a party presents to act on a room. Carries the whole authority chain: a host MUST NOT dereference an authority credential's `parent` to fetch a link it was not given. Resolving over the network would make verification depend on availability, turn every identifier into a request the host can be induced to make against an address the holder chooses, and signal credential use to whoever hosts the identifier. A host MUST bind the presenter to the chain's leaf. A chain that verifies is evidence that authority was conferred on somebody; it is not evidence that the party presenting it is that somebody. The leaf's subject MUST equal the party the host authenticated for this request — an identity the transport established or a document `proof` proved, never one named in a payload. A host that omits this check authorizes every captured presentation, and the omission is silent, because the chain still verifies.",
/// "type": "object",
/// "required": [
/// "authority",
/// "membership"
/// ],
/// "properties": {
/// "authority": {
/// "description": "The authority chain, LEAF FIRST: the first element is the credential being relied on and the last MUST be one issued by the room itself. Every link the presenter relies on is present, because the host will not fetch one. Capped at 8: verification is linear in chain length and runs on every operation, so an unbounded chain is a denial-of-service surface against the host. The known uses need 2 to 3 — a person attenuating to an agent, and that agent to a sub-agent.",
/// "type": "array",
/// "items": {
/// "type": "string"
/// },
/// "maxItems": 8,
/// "minItems": 1
/// },
/// "membership": {
/// "description": "The presenter's membership credential for this room, or — on a `private` room — a zero-knowledge presentation of it. Serialized per the governing profile.",
/// "type": "string"
/// },
/// "subjectBinding": {
/// "description": "REQUIRED on a `private` room, where the subject identifier is withheld: a proof that the membership credential and the authority chain's leaf describe the SAME subject. Without it two parties pool credentials — one contributes membership, the other authority — and the combination verifies as a single party holding both. A host MUST refuse a private-room presentation that omits this.",
/// "type": "string"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct AuthorityPresentation {
///The authority chain, LEAF FIRST: the first element is the credential being relied on and the last MUST be one issued by the room itself. Every link the presenter relies on is present, because the host will not fetch one. Capped at 8: verification is linear in chain length and runs on every operation, so an unbounded chain is a denial-of-service surface against the host. The known uses need 2 to 3 — a person attenuating to an agent, and that agent to a sub-agent.
pub authority: ::std::vec::Vec<::std::string::String>,
///The presenter's membership credential for this room, or — on a `private` room — a zero-knowledge presentation of it. Serialized per the governing profile.
pub membership: ::std::string::String,
///REQUIRED on a `private` room, where the subject identifier is withheld: a proof that the membership credential and the authority chain's leaf describe the SAME subject. Without it two parties pool credentials — one contributes membership, the other authority — and the combination verifies as a single party holding both. A host MUST refuse a private-room presentation that omits this.
#[serde(
rename = "subjectBinding",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub subject_binding: ::std::option::Option<::std::string::String>,
}
impl AuthorityPresentation {
pub fn builder() -> builder::AuthorityPresentation {
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())
})
}
}
///`MemberUsage`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "MemberUsage",
/// "type": "object",
/// "required": [
/// "limits",
/// "member",
/// "usage"
/// ],
/// "properties": {
/// "lastUploadAt": {
/// "description": "When this member last committed a blob in the room.",
/// "type": "string",
/// "format": "date-time"
/// },
/// "limits": {
/// "description": "The limits that apply to this member in this room: their override if one is set, else the room's per-member default.",
/// "$ref": "#/definitions/ScopeLimits"
/// },
/// "member": {
/// "description": "The member's DID: the subject at the room end of the chains they presented when uploading. Uploads by a member's agents are counted here, under the member.",
/// "type": "string",
/// "maxLength": 2048,
/// "pattern": "^did:[a-z0-9]+:.+$"
/// },
/// "overridden": {
/// "description": "True when `limits` is an override set for this member rather than the room's default.",
/// "type": "boolean"
/// },
/// "usage": {
/// "$ref": "#/definitions/Usage"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct MemberUsage {
///When this member last committed a blob in the room.
#[serde(
rename = "lastUploadAt",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub last_upload_at: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
///The limits that apply to this member in this room: their override if one is set, else the room's per-member default.
pub limits: ScopeLimits,
///The member's DID: the subject at the room end of the chains they presented when uploading. Uploads by a member's agents are counted here, under the member.
pub member: MemberUsageMember,
///True when `limits` is an override set for this member rather than the room's default.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub overridden: ::std::option::Option<bool>,
pub usage: Usage,
}
impl MemberUsage {
pub fn builder() -> builder::MemberUsage {
Default::default()
}
}
///The member's DID: the subject at the room end of the chains they presented when uploading. Uploads by a member's agents are counted here, under the member.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The member's DID: the subject at the room end of the chains they presented when uploading. Uploads by a member's agents are counted here, under the member.",
/// "type": "string",
/// "maxLength": 2048,
/// "pattern": "^did:[a-z0-9]+:.+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct MemberUsageMember(::std::string::String);
impl ::std::ops::Deref for MemberUsageMember {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<MemberUsageMember> for ::std::string::String {
fn from(value: MemberUsageMember) -> Self {
value.0
}
}
impl ::std::str::FromStr for MemberUsageMember {
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:[a-z0-9]+:.+$").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^did:[a-z0-9]+:.+$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for MemberUsageMember {
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 MemberUsageMember {
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 MemberUsageMember {
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 MemberUsageMember {
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 room's owner reads how much each member who has added files is using, against their allowance. Authorized by the room's own credentials: a chain conferring `admin` at the room's scope.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/rooms/usage/0.1",
/// "title": "Payload",
/// "description": "A room's owner reads how much each member who has added files is using, against their allowance. Authorized by the room's own credentials: a chain conferring `admin` at the room's scope.",
/// "type": "object",
/// "required": [
/// "presentation",
/// "roomId"
/// ],
/// "properties": {
/// "cursor": {
/// "description": "Opaque continuation from a previous response's `nextCursor`. Omit for the first page.",
/// "type": "string",
/// "maxLength": 512
/// },
/// "ext": {
/// "description": "Ecosystem-defined extension members per SPEC.md §4.5.1.",
/// "$ref": "#/definitions/Ext"
/// },
/// "limit": {
/// "description": "Most entries to return. The host chooses when omitted, and may return fewer.",
/// "type": "integer",
/// "maximum": 500.0,
/// "minimum": 1.0
/// },
/// "presentation": {
/// "description": "Must confer the `admin` action at this room's scope.",
/// "$ref": "#/definitions/AuthorityPresentation"
/// },
/// "roomId": {
/// "description": "The room's identifier. The host verifies the presentation against credentials issued by this identifier.",
/// "type": "string"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///Opaque continuation from a previous response's `nextCursor`. Omit for the first page.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub cursor: ::std::option::Option<PayloadCursor>,
///Ecosystem-defined extension members per SPEC.md §4.5.1.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///Most entries to return. The host chooses when omitted, and may return fewer.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub limit: ::std::option::Option<::std::num::NonZeroU64>,
///Must confer the `admin` action at this room's scope.
pub presentation: AuthorityPresentation,
///The room's identifier. The host verifies the presentation against credentials issued by this identifier.
#[serde(rename = "roomId")]
pub room_id: ::std::string::String,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///Opaque continuation from a previous response's `nextCursor`. Omit for the first page.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Opaque continuation from a previous response's `nextCursor`. Omit for the first page.",
/// "type": "string",
/// "maxLength": 512
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadCursor(::std::string::String);
impl ::std::ops::Deref for PayloadCursor {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadCursor> for ::std::string::String {
fn from(value: PayloadCursor) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadCursor {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 512usize {
return Err("longer than 512 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadCursor {
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 PayloadCursor {
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 PayloadCursor {
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 PayloadCursor {
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())
})
}
}
///Success response to rooms/usage. Type https://trusttasks.org/spec/rooms/usage/0.1#response.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "Success response to rooms/usage. Type https://trusttasks.org/spec/rooms/usage/0.1#response.",
/// "type": "object",
/// "required": [
/// "members",
/// "roomId"
/// ],
/// "properties": {
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "members": {
/// "description": "One entry per member who holds or has reserved storage in the room, or holds an override. Not a roster: a member who has never added a file does not appear, because the host has never been told about them.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/MemberUsage"
/// },
/// "maxItems": 500
/// },
/// "nextCursor": {
/// "description": "Present exactly when more entries remain.",
/// "type": "string",
/// "maxLength": 512
/// },
/// "roomId": {
/// "description": "The room this describes.",
/// "type": "string"
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///One entry per member who holds or has reserved storage in the room, or holds an override. Not a roster: a member who has never added a file does not appear, because the host has never been told about them.
pub members: ::std::vec::Vec<MemberUsage>,
///Present exactly when more entries remain.
#[serde(
rename = "nextCursor",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub next_cursor: ::std::option::Option<ResponseNextCursor>,
///The room this describes.
#[serde(rename = "roomId")]
pub room_id: ::std::string::String,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///Present exactly when more entries remain.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Present exactly when more entries remain.",
/// "type": "string",
/// "maxLength": 512
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseNextCursor(::std::string::String);
impl ::std::ops::Deref for ResponseNextCursor {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseNextCursor> for ::std::string::String {
fn from(value: ResponseNextCursor) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseNextCursor {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 512usize {
return Err("longer than 512 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ResponseNextCursor {
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 ResponseNextCursor {
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 ResponseNextCursor {
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 ResponseNextCursor {
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())
})
}
}
///Limits at one scope. Every member is optional: an absent member means the scope sets no limit of that kind, and the next wider scope's limit, or the host's ceiling, governs. All sizes are ciphertext bytes.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ScopeLimits",
/// "description": "Limits at one scope. Every member is optional: an absent member means the scope sets no limit of that kind, and the next wider scope's limit, or the host's ceiling, governs. All sizes are ciphertext bytes.",
/// "type": "object",
/// "properties": {
/// "maxBytes": {
/// "description": "The total size of the committed and reserved blobs the scope may hold.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "maxFileBytes": {
/// "description": "The largest single blob the scope accepts. Never above 1 GiB, the transfer ceiling (BlobManifest).",
/// "type": "integer",
/// "maximum": 1073741824.0,
/// "minimum": 0.0
/// },
/// "maxFiles": {
/// "description": "The number of committed blobs the scope may hold. 0 refuses every upload at this scope.",
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ScopeLimits {
///The total size of the committed and reserved blobs the scope may hold.
#[serde(
rename = "maxBytes",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub max_bytes: ::std::option::Option<u64>,
///The largest single blob the scope accepts. Never above 1 GiB, the transfer ceiling (BlobManifest).
#[serde(
rename = "maxFileBytes",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub max_file_bytes: ::std::option::Option<i64>,
///The number of committed blobs the scope may hold. 0 refuses every upload at this scope.
#[serde(
rename = "maxFiles",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub max_files: ::std::option::Option<u64>,
}
impl ::std::default::Default for ScopeLimits {
fn default() -> Self {
Self {
max_bytes: Default::default(),
max_file_bytes: Default::default(),
max_files: Default::default(),
}
}
}
impl ScopeLimits {
pub fn builder() -> builder::ScopeLimits {
Default::default()
}
}
///What one scope holds now. Ciphertext bytes throughout.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Usage",
/// "description": "What one scope holds now. Ciphertext bytes throughout.",
/// "type": "object",
/// "required": [
/// "bytes",
/// "files",
/// "reservedBytes"
/// ],
/// "properties": {
/// "bytes": {
/// "description": "Their total size. A blob stops counting the moment it is orphaned (its last record dropped it or was retracted), not when the host finally deletes it, so a member who deletes a file has the room back at once.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "files": {
/// "description": "Committed blobs that are not orphaned.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "reservedBytes": {
/// "description": "Bytes reserved by uploads begun and not yet committed, aborted or expired. Counted against `maxBytes`, so two concurrent uploads cannot both fit under a limit only one of them fits.",
/// "type": "integer",
/// "minimum": 0.0
/// },
/// "reservedFiles": {
/// "description": "Uploads begun and not yet committed, aborted or expired. Counted against `maxFiles`.",
/// "type": "integer",
/// "minimum": 0.0
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Usage {
///Their total size. A blob stops counting the moment it is orphaned (its last record dropped it or was retracted), not when the host finally deletes it, so a member who deletes a file has the room back at once.
pub bytes: u64,
///Committed blobs that are not orphaned.
pub files: u64,
///Bytes reserved by uploads begun and not yet committed, aborted or expired. Counted against `maxBytes`, so two concurrent uploads cannot both fit under a limit only one of them fits.
#[serde(rename = "reservedBytes")]
pub reserved_bytes: u64,
///Uploads begun and not yet committed, aborted or expired. Counted against `maxFiles`.
#[serde(
rename = "reservedFiles",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub reserved_files: ::std::option::Option<u64>,
}
impl Usage {
pub fn builder() -> builder::Usage {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct AuthorityPresentation {
authority:
::std::result::Result<::std::vec::Vec<::std::string::String>, ::std::string::String>,
membership: ::std::result::Result<::std::string::String, ::std::string::String>,
subject_binding: ::std::result::Result<
::std::option::Option<::std::string::String>,
::std::string::String,
>,
}
impl ::std::default::Default for AuthorityPresentation {
fn default() -> Self {
Self {
authority: Err("no value supplied for authority".to_string()),
membership: Err("no value supplied for membership".to_string()),
subject_binding: Ok(Default::default()),
}
}
}
impl AuthorityPresentation {
pub fn authority<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.authority = value
.try_into()
.map_err(|e| format!("error converting supplied value for authority: {e}"));
self
}
pub fn membership<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.membership = value
.try_into()
.map_err(|e| format!("error converting supplied value for membership: {e}"));
self
}
pub fn subject_binding<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::string::String>>,
T::Error: ::std::fmt::Display,
{
self.subject_binding = value
.try_into()
.map_err(|e| format!("error converting supplied value for subject_binding: {e}"));
self
}
}
impl ::std::convert::TryFrom<AuthorityPresentation> for super::AuthorityPresentation {
type Error = super::error::ConversionError;
fn try_from(
value: AuthorityPresentation,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
authority: value.authority?,
membership: value.membership?,
subject_binding: value.subject_binding?,
})
}
}
impl ::std::convert::From<super::AuthorityPresentation> for AuthorityPresentation {
fn from(value: super::AuthorityPresentation) -> Self {
Self {
authority: Ok(value.authority),
membership: Ok(value.membership),
subject_binding: Ok(value.subject_binding),
}
}
}
#[derive(Clone, Debug)]
pub struct MemberUsage {
last_upload_at: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
limits: ::std::result::Result<super::ScopeLimits, ::std::string::String>,
member: ::std::result::Result<super::MemberUsageMember, ::std::string::String>,
overridden: ::std::result::Result<::std::option::Option<bool>, ::std::string::String>,
usage: ::std::result::Result<super::Usage, ::std::string::String>,
}
impl ::std::default::Default for MemberUsage {
fn default() -> Self {
Self {
last_upload_at: Ok(Default::default()),
limits: Err("no value supplied for limits".to_string()),
member: Err("no value supplied for member".to_string()),
overridden: Ok(Default::default()),
usage: Err("no value supplied for usage".to_string()),
}
}
}
impl MemberUsage {
pub fn last_upload_at<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
>,
T::Error: ::std::fmt::Display,
{
self.last_upload_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for last_upload_at: {e}"));
self
}
pub fn limits<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ScopeLimits>,
T::Error: ::std::fmt::Display,
{
self.limits = value
.try_into()
.map_err(|e| format!("error converting supplied value for limits: {e}"));
self
}
pub fn member<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::MemberUsageMember>,
T::Error: ::std::fmt::Display,
{
self.member = value
.try_into()
.map_err(|e| format!("error converting supplied value for member: {e}"));
self
}
pub fn overridden<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<bool>>,
T::Error: ::std::fmt::Display,
{
self.overridden = value
.try_into()
.map_err(|e| format!("error converting supplied value for overridden: {e}"));
self
}
pub fn usage<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Usage>,
T::Error: ::std::fmt::Display,
{
self.usage = value
.try_into()
.map_err(|e| format!("error converting supplied value for usage: {e}"));
self
}
}
impl ::std::convert::TryFrom<MemberUsage> for super::MemberUsage {
type Error = super::error::ConversionError;
fn try_from(
value: MemberUsage,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
last_upload_at: value.last_upload_at?,
limits: value.limits?,
member: value.member?,
overridden: value.overridden?,
usage: value.usage?,
})
}
}
impl ::std::convert::From<super::MemberUsage> for MemberUsage {
fn from(value: super::MemberUsage) -> Self {
Self {
last_upload_at: Ok(value.last_upload_at),
limits: Ok(value.limits),
member: Ok(value.member),
overridden: Ok(value.overridden),
usage: Ok(value.usage),
}
}
}
#[derive(Clone, Debug)]
pub struct Payload {
cursor: ::std::result::Result<
::std::option::Option<super::PayloadCursor>,
::std::string::String,
>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
limit: ::std::result::Result<
::std::option::Option<::std::num::NonZeroU64>,
::std::string::String,
>,
presentation: ::std::result::Result<super::AuthorityPresentation, ::std::string::String>,
room_id: ::std::result::Result<::std::string::String, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
cursor: Ok(Default::default()),
ext: Ok(Default::default()),
limit: Ok(Default::default()),
presentation: Err("no value supplied for presentation".to_string()),
room_id: Err("no value supplied for room_id".to_string()),
}
}
}
impl Payload {
pub fn cursor<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadCursor>>,
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 limit<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<::std::num::NonZeroU64>>,
T::Error: ::std::fmt::Display,
{
self.limit = value
.try_into()
.map_err(|e| format!("error converting supplied value for limit: {e}"));
self
}
pub fn presentation<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::AuthorityPresentation>,
T::Error: ::std::fmt::Display,
{
self.presentation = value
.try_into()
.map_err(|e| format!("error converting supplied value for presentation: {e}"));
self
}
pub fn room_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.room_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for room_id: {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 {
cursor: value.cursor?,
ext: value.ext?,
limit: value.limit?,
presentation: value.presentation?,
room_id: value.room_id?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
cursor: Ok(value.cursor),
ext: Ok(value.ext),
limit: Ok(value.limit),
presentation: Ok(value.presentation),
room_id: Ok(value.room_id),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
members: ::std::result::Result<::std::vec::Vec<super::MemberUsage>, ::std::string::String>,
next_cursor: ::std::result::Result<
::std::option::Option<super::ResponseNextCursor>,
::std::string::String,
>,
room_id: ::std::result::Result<::std::string::String, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
members: Err("no value supplied for members".to_string()),
next_cursor: Ok(Default::default()),
room_id: Err("no value supplied for room_id".to_string()),
}
}
}
impl Response {
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 members<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::MemberUsage>>,
T::Error: ::std::fmt::Display,
{
self.members = value
.try_into()
.map_err(|e| format!("error converting supplied value for members: {e}"));
self
}
pub fn next_cursor<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ResponseNextCursor>>,
T::Error: ::std::fmt::Display,
{
self.next_cursor = value
.try_into()
.map_err(|e| format!("error converting supplied value for next_cursor: {e}"));
self
}
pub fn room_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::string::String>,
T::Error: ::std::fmt::Display,
{
self.room_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for room_id: {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 {
ext: value.ext?,
members: value.members?,
next_cursor: value.next_cursor?,
room_id: value.room_id?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
ext: Ok(value.ext),
members: Ok(value.members),
next_cursor: Ok(value.next_cursor),
room_id: Ok(value.room_id),
}
}
}
#[derive(Clone, Debug)]
pub struct ScopeLimits {
max_bytes: ::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
max_file_bytes: ::std::result::Result<::std::option::Option<i64>, ::std::string::String>,
max_files: ::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
}
impl ::std::default::Default for ScopeLimits {
fn default() -> Self {
Self {
max_bytes: Ok(Default::default()),
max_file_bytes: Ok(Default::default()),
max_files: Ok(Default::default()),
}
}
}
impl ScopeLimits {
pub fn max_bytes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.max_bytes = value
.try_into()
.map_err(|e| format!("error converting supplied value for max_bytes: {e}"));
self
}
pub fn max_file_bytes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<i64>>,
T::Error: ::std::fmt::Display,
{
self.max_file_bytes = value
.try_into()
.map_err(|e| format!("error converting supplied value for max_file_bytes: {e}"));
self
}
pub fn max_files<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.max_files = value
.try_into()
.map_err(|e| format!("error converting supplied value for max_files: {e}"));
self
}
}
impl ::std::convert::TryFrom<ScopeLimits> for super::ScopeLimits {
type Error = super::error::ConversionError;
fn try_from(
value: ScopeLimits,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
max_bytes: value.max_bytes?,
max_file_bytes: value.max_file_bytes?,
max_files: value.max_files?,
})
}
}
impl ::std::convert::From<super::ScopeLimits> for ScopeLimits {
fn from(value: super::ScopeLimits) -> Self {
Self {
max_bytes: Ok(value.max_bytes),
max_file_bytes: Ok(value.max_file_bytes),
max_files: Ok(value.max_files),
}
}
}
#[derive(Clone, Debug)]
pub struct Usage {
bytes: ::std::result::Result<u64, ::std::string::String>,
files: ::std::result::Result<u64, ::std::string::String>,
reserved_bytes: ::std::result::Result<u64, ::std::string::String>,
reserved_files: ::std::result::Result<::std::option::Option<u64>, ::std::string::String>,
}
impl ::std::default::Default for Usage {
fn default() -> Self {
Self {
bytes: Err("no value supplied for bytes".to_string()),
files: Err("no value supplied for files".to_string()),
reserved_bytes: Err("no value supplied for reserved_bytes".to_string()),
reserved_files: Ok(Default::default()),
}
}
}
impl Usage {
pub fn bytes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.bytes = value
.try_into()
.map_err(|e| format!("error converting supplied value for bytes: {e}"));
self
}
pub fn files<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.files = value
.try_into()
.map_err(|e| format!("error converting supplied value for files: {e}"));
self
}
pub fn reserved_bytes<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<u64>,
T::Error: ::std::fmt::Display,
{
self.reserved_bytes = value
.try_into()
.map_err(|e| format!("error converting supplied value for reserved_bytes: {e}"));
self
}
pub fn reserved_files<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<u64>>,
T::Error: ::std::fmt::Display,
{
self.reserved_files = value
.try_into()
.map_err(|e| format!("error converting supplied value for reserved_files: {e}"));
self
}
}
impl ::std::convert::TryFrom<Usage> for super::Usage {
type Error = super::error::ConversionError;
fn try_from(value: Usage) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
bytes: value.bytes?,
files: value.files?,
reserved_bytes: value.reserved_bytes?,
reserved_files: value.reserved_files?,
})
}
}
impl ::std::convert::From<super::Usage> for Usage {
fn from(value: super::Usage) -> Self {
Self {
bytes: Ok(value.bytes),
files: Ok(value.files),
reserved_bytes: Ok(value.reserved_bytes),
reserved_files: Ok(value.reserved_files),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/rooms/usage/0.1";
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"AuthorityPresentation\": {\n \"additionalProperties\": false,\n \"description\": \"What a party presents to act on a room. Carries the whole authority chain: a host MUST NOT dereference an authority credential's `parent` to fetch a link it was not given. Resolving over the network would make verification depend on availability, turn every identifier into a request the host can be induced to make against an address the holder chooses, and signal credential use to whoever hosts the identifier. A host MUST bind the presenter to the chain's leaf. A chain that verifies is evidence that authority was conferred on somebody; it is not evidence that the party presenting it is that somebody. The leaf's subject MUST equal the party the host authenticated for this request — an identity the transport established or a document `proof` proved, never one named in a payload. A host that omits this check authorizes every captured presentation, and the omission is silent, because the chain still verifies.\",\n \"properties\": {\n \"authority\": {\n \"description\": \"The authority chain, LEAF FIRST: the first element is the credential being relied on and the last MUST be one issued by the room itself. Every link the presenter relies on is present, because the host will not fetch one. Capped at 8: verification is linear in chain length and runs on every operation, so an unbounded chain is a denial-of-service surface against the host. The known uses need 2 to 3 — a person attenuating to an agent, and that agent to a sub-agent.\",\n \"items\": {\n \"type\": \"string\"\n },\n \"maxItems\": 8,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"membership\": {\n \"description\": \"The presenter's membership credential for this room, or — on a `private` room — a zero-knowledge presentation of it. Serialized per the governing profile.\",\n \"type\": \"string\"\n },\n \"subjectBinding\": {\n \"description\": \"REQUIRED on a `private` room, where the subject identifier is withheld: a proof that the membership credential and the authority chain's leaf describe the SAME subject. Without it two parties pool credentials — one contributes membership, the other authority — and the combination verifies as a single party holding both. A host MUST refuse a private-room presentation that omits this.\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"membership\",\n \"authority\"\n ],\n \"title\": \"AuthorityPresentation\",\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 \"MemberUsage\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"lastUploadAt\": {\n \"description\": \"When this member last committed a blob in the room.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"limits\": {\n \"$ref\": \"#/$defs/ScopeLimits\",\n \"description\": \"The limits that apply to this member in this room: their override if one is set, else the room's per-member default.\"\n },\n \"member\": {\n \"description\": \"The member's DID: the subject at the room end of the chains they presented when uploading. Uploads by a member's agents are counted here, under the member.\",\n \"maxLength\": 2048,\n \"pattern\": \"^did:[a-z0-9]+:.+$\",\n \"type\": \"string\"\n },\n \"overridden\": {\n \"description\": \"True when `limits` is an override set for this member rather than the room's default.\",\n \"type\": \"boolean\"\n },\n \"usage\": {\n \"$ref\": \"#/$defs/Usage\"\n }\n },\n \"required\": [\n \"member\",\n \"usage\",\n \"limits\"\n ],\n \"title\": \"MemberUsage\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"Success response to rooms/usage. Type https://trusttasks.org/spec/rooms/usage/0.1#response.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"members\": {\n \"description\": \"One entry per member who holds or has reserved storage in the room, or holds an override. Not a roster: a member who has never added a file does not appear, because the host has never been told about them.\",\n \"items\": {\n \"$ref\": \"#/$defs/MemberUsage\"\n },\n \"maxItems\": 500,\n \"type\": \"array\"\n },\n \"nextCursor\": {\n \"description\": \"Present exactly when more entries remain.\",\n \"maxLength\": 512,\n \"type\": \"string\"\n },\n \"roomId\": {\n \"description\": \"The room this describes.\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"roomId\",\n \"members\"\n ],\n \"title\": \"Rooms Usage — response payload\",\n \"type\": \"object\"\n },\n \"ScopeLimits\": {\n \"additionalProperties\": false,\n \"description\": \"Limits at one scope. Every member is optional: an absent member means the scope sets no limit of that kind, and the next wider scope's limit, or the host's ceiling, governs. All sizes are ciphertext bytes.\",\n \"properties\": {\n \"maxBytes\": {\n \"description\": \"The total size of the committed and reserved blobs the scope may hold.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"maxFileBytes\": {\n \"description\": \"The largest single blob the scope accepts. Never above 1 GiB, the transfer ceiling (BlobManifest).\",\n \"maximum\": 1073741824,\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"maxFiles\": {\n \"description\": \"The number of committed blobs the scope may hold. 0 refuses every upload at this scope.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"title\": \"ScopeLimits\",\n \"type\": \"object\"\n },\n \"Usage\": {\n \"additionalProperties\": false,\n \"description\": \"What one scope holds now. Ciphertext bytes throughout.\",\n \"properties\": {\n \"bytes\": {\n \"description\": \"Their total size. A blob stops counting the moment it is orphaned (its last record dropped it or was retracted), not when the host finally deletes it, so a member who deletes a file has the room back at once.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"files\": {\n \"description\": \"Committed blobs that are not orphaned.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"reservedBytes\": {\n \"description\": \"Bytes reserved by uploads begun and not yet committed, aborted or expired. Counted against `maxBytes`, so two concurrent uploads cannot both fit under a limit only one of them fits.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"reservedFiles\": {\n \"description\": \"Uploads begun and not yet committed, aborted or expired. Counted against `maxFiles`.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"files\",\n \"bytes\",\n \"reservedBytes\"\n ],\n \"title\": \"Usage\",\n \"type\": \"object\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/rooms/usage/0.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"A room's owner reads how much each member who has added files is using, against their allowance. Authorized by the room's own credentials: a chain conferring `admin` at the room's scope.\",\n \"properties\": {\n \"cursor\": {\n \"description\": \"Opaque continuation from a previous response's `nextCursor`. Omit for the first page.\",\n \"maxLength\": 512,\n \"type\": \"string\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\",\n \"description\": \"Ecosystem-defined extension members per SPEC.md §4.5.1.\"\n },\n \"limit\": {\n \"description\": \"Most entries to return. The host chooses when omitted, and may return fewer.\",\n \"maximum\": 500,\n \"minimum\": 1,\n \"type\": \"integer\"\n },\n \"presentation\": {\n \"$ref\": \"#/$defs/AuthorityPresentation\",\n \"description\": \"Must confer the `admin` action at this room's scope.\"\n },\n \"roomId\": {\n \"description\": \"The room's identifier. The host verifies the presentation against credentials issued by this identifier.\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"roomId\",\n \"presentation\"\n ],\n \"title\": \"Rooms Usage — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/rooms/usage/0.1#response";
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"AuthorityPresentation\": {\n \"additionalProperties\": false,\n \"description\": \"What a party presents to act on a room. Carries the whole authority chain: a host MUST NOT dereference an authority credential's `parent` to fetch a link it was not given. Resolving over the network would make verification depend on availability, turn every identifier into a request the host can be induced to make against an address the holder chooses, and signal credential use to whoever hosts the identifier. A host MUST bind the presenter to the chain's leaf. A chain that verifies is evidence that authority was conferred on somebody; it is not evidence that the party presenting it is that somebody. The leaf's subject MUST equal the party the host authenticated for this request — an identity the transport established or a document `proof` proved, never one named in a payload. A host that omits this check authorizes every captured presentation, and the omission is silent, because the chain still verifies.\",\n \"properties\": {\n \"authority\": {\n \"description\": \"The authority chain, LEAF FIRST: the first element is the credential being relied on and the last MUST be one issued by the room itself. Every link the presenter relies on is present, because the host will not fetch one. Capped at 8: verification is linear in chain length and runs on every operation, so an unbounded chain is a denial-of-service surface against the host. The known uses need 2 to 3 — a person attenuating to an agent, and that agent to a sub-agent.\",\n \"items\": {\n \"type\": \"string\"\n },\n \"maxItems\": 8,\n \"minItems\": 1,\n \"type\": \"array\"\n },\n \"membership\": {\n \"description\": \"The presenter's membership credential for this room, or — on a `private` room — a zero-knowledge presentation of it. Serialized per the governing profile.\",\n \"type\": \"string\"\n },\n \"subjectBinding\": {\n \"description\": \"REQUIRED on a `private` room, where the subject identifier is withheld: a proof that the membership credential and the authority chain's leaf describe the SAME subject. Without it two parties pool credentials — one contributes membership, the other authority — and the combination verifies as a single party holding both. A host MUST refuse a private-room presentation that omits this.\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"membership\",\n \"authority\"\n ],\n \"title\": \"AuthorityPresentation\",\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 \"MemberUsage\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"lastUploadAt\": {\n \"description\": \"When this member last committed a blob in the room.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"limits\": {\n \"$ref\": \"#/$defs/ScopeLimits\",\n \"description\": \"The limits that apply to this member in this room: their override if one is set, else the room's per-member default.\"\n },\n \"member\": {\n \"description\": \"The member's DID: the subject at the room end of the chains they presented when uploading. Uploads by a member's agents are counted here, under the member.\",\n \"maxLength\": 2048,\n \"pattern\": \"^did:[a-z0-9]+:.+$\",\n \"type\": \"string\"\n },\n \"overridden\": {\n \"description\": \"True when `limits` is an override set for this member rather than the room's default.\",\n \"type\": \"boolean\"\n },\n \"usage\": {\n \"$ref\": \"#/$defs/Usage\"\n }\n },\n \"required\": [\n \"member\",\n \"usage\",\n \"limits\"\n ],\n \"title\": \"MemberUsage\",\n \"type\": \"object\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"Success response to rooms/usage. Type https://trusttasks.org/spec/rooms/usage/0.1#response.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"members\": {\n \"description\": \"One entry per member who holds or has reserved storage in the room, or holds an override. Not a roster: a member who has never added a file does not appear, because the host has never been told about them.\",\n \"items\": {\n \"$ref\": \"#/$defs/MemberUsage\"\n },\n \"maxItems\": 500,\n \"type\": \"array\"\n },\n \"nextCursor\": {\n \"description\": \"Present exactly when more entries remain.\",\n \"maxLength\": 512,\n \"type\": \"string\"\n },\n \"roomId\": {\n \"description\": \"The room this describes.\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"roomId\",\n \"members\"\n ],\n \"title\": \"Rooms Usage — response payload\",\n \"type\": \"object\"\n },\n \"ScopeLimits\": {\n \"additionalProperties\": false,\n \"description\": \"Limits at one scope. Every member is optional: an absent member means the scope sets no limit of that kind, and the next wider scope's limit, or the host's ceiling, governs. All sizes are ciphertext bytes.\",\n \"properties\": {\n \"maxBytes\": {\n \"description\": \"The total size of the committed and reserved blobs the scope may hold.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"maxFileBytes\": {\n \"description\": \"The largest single blob the scope accepts. Never above 1 GiB, the transfer ceiling (BlobManifest).\",\n \"maximum\": 1073741824,\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"maxFiles\": {\n \"description\": \"The number of committed blobs the scope may hold. 0 refuses every upload at this scope.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"title\": \"ScopeLimits\",\n \"type\": \"object\"\n },\n \"Usage\": {\n \"additionalProperties\": false,\n \"description\": \"What one scope holds now. Ciphertext bytes throughout.\",\n \"properties\": {\n \"bytes\": {\n \"description\": \"Their total size. A blob stops counting the moment it is orphaned (its last record dropped it or was retracted), not when the host finally deletes it, so a member who deletes a file has the room back at once.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"files\": {\n \"description\": \"Committed blobs that are not orphaned.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"reservedBytes\": {\n \"description\": \"Bytes reserved by uploads begun and not yet committed, aborted or expired. Counted against `maxBytes`, so two concurrent uploads cannot both fit under a limit only one of them fits.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n },\n \"reservedFiles\": {\n \"description\": \"Uploads begun and not yet committed, aborted or expired. Counted against `maxFiles`.\",\n \"minimum\": 0,\n \"type\": \"integer\"\n }\n },\n \"required\": [\n \"files\",\n \"bytes\",\n \"reservedBytes\"\n ],\n \"title\": \"Usage\",\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::CHAIN_TOO_DEEP, error_codes::NOT_AVAILABLE];
/// 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 {
/// `rooms/usage:chainTooDeep`
///
/// The authority chain exceeds the maximum of 8 links.
///
/// Declared `retryable: false`.
pub const CHAIN_TOO_DEEP: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "rooms/usage:chainTooDeep",
retryable: false,
details_schema: ::core::option::Option::None,
};
/// `rooms/usage:notAvailable`
///
/// The room is `private`. The host does not know which member uploaded what, so there is no per-member usage to report; room totals are in rooms/info.
///
/// Declared `retryable: false`.
pub const NOT_AVAILABLE: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "rooms/usage:notAvailable",
retryable: false,
details_schema: ::core::option::Option::None,
};
}