//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `git-ns/bridge/event`. 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())
}
}
}
///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())
})
}
}
///One forge-neutral event, discriminated by `type`. The specification's event table says what each type means and what the VTC does with it.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "ForgeEvent",
/// "description": "One forge-neutral event, discriminated by `type`. The specification's event table says what each type means and what the VTC does with it.",
/// "type": "object",
/// "oneOf": [
/// {
/// "title": "RepoRenamed",
/// "type": "object",
/// "required": [
/// "forgeId",
/// "from",
/// "to",
/// "type"
/// ],
/// "properties": {
/// "forgeId": {
/// "$ref": "#/definitions/ForgeId"
/// },
/// "from": {
/// "$ref": "#/definitions/RepoResource"
/// },
/// "to": {
/// "$ref": "#/definitions/RepoResource"
/// },
/// "type": {
/// "const": "repoRenamed"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "RepoTransferred",
/// "type": "object",
/// "required": [
/// "forgeId",
/// "from",
/// "to",
/// "type"
/// ],
/// "properties": {
/// "forgeId": {
/// "$ref": "#/definitions/ForgeId"
/// },
/// "from": {
/// "$ref": "#/definitions/RepoResource"
/// },
/// "to": {
/// "$ref": "#/definitions/RepoResource"
/// },
/// "type": {
/// "const": "repoTransferred"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "RepoCreatedUnmanaged",
/// "type": "object",
/// "required": [
/// "forgeId",
/// "resource",
/// "type"
/// ],
/// "properties": {
/// "forgeId": {
/// "$ref": "#/definitions/ForgeId"
/// },
/// "resource": {
/// "$ref": "#/definitions/RepoResource"
/// },
/// "type": {
/// "const": "repoCreatedUnmanaged"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "RepoDeleted",
/// "type": "object",
/// "required": [
/// "forgeId",
/// "resource",
/// "type"
/// ],
/// "properties": {
/// "forgeId": {
/// "$ref": "#/definitions/ForgeId"
/// },
/// "resource": {
/// "$ref": "#/definitions/RepoResource"
/// },
/// "type": {
/// "const": "repoDeleted"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "RoleChanged",
/// "type": "object",
/// "required": [
/// "account",
/// "forgeId",
/// "resource",
/// "type"
/// ],
/// "properties": {
/// "account": {
/// "$ref": "#/definitions/ForgeAccount"
/// },
/// "forgeId": {
/// "$ref": "#/definitions/ForgeId"
/// },
/// "resource": {
/// "$ref": "#/definitions/RepoResource"
/// },
/// "role": {
/// "description": "The role the account now holds. Absent: the account holds no role now.",
/// "$ref": "#/definitions/ForgeRole"
/// },
/// "type": {
/// "const": "roleChanged"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "ProtectionChanged",
/// "type": "object",
/// "required": [
/// "forgeId",
/// "requiredCheck",
/// "resource",
/// "type"
/// ],
/// "properties": {
/// "forgeId": {
/// "$ref": "#/definitions/ForgeId"
/// },
/// "requiredCheck": {
/// "description": "Whether the forge still refuses merges without a passing verify-trust check, with no bypass.",
/// "type": "boolean"
/// },
/// "resource": {
/// "$ref": "#/definitions/RepoResource"
/// },
/// "type": {
/// "const": "protectionChanged"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "InstallationRemoved",
/// "type": "object",
/// "required": [
/// "type"
/// ],
/// "properties": {
/// "type": {
/// "const": "installationRemoved"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "AccountLinked",
/// "type": "object",
/// "required": [
/// "account",
/// "jobId",
/// "type"
/// ],
/// "properties": {
/// "account": {
/// "$ref": "#/definitions/ForgeAccount"
/// },
/// "jobId": {
/// "description": "The beginAccountLink job.",
/// "$ref": "#/definitions/JobId"
/// },
/// "type": {
/// "const": "accountLinked"
/// }
/// },
/// "additionalProperties": false
/// },
/// {
/// "title": "BindCompleted",
/// "type": "object",
/// "required": [
/// "jobId",
/// "kind",
/// "ownerId",
/// "type"
/// ],
/// "properties": {
/// "jobId": {
/// "description": "The beginBind job.",
/// "$ref": "#/definitions/JobId"
/// },
/// "kind": {
/// "type": "string",
/// "enum": [
/// "organization",
/// "user"
/// ]
/// },
/// "ownerId": {
/// "description": "The forge's id for the owner, which survives renames.",
/// "$ref": "#/definitions/ForgeId"
/// },
/// "type": {
/// "const": "bindCompleted"
/// }
/// },
/// "additionalProperties": false
/// }
/// ]
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(tag = "type", deny_unknown_fields)]
#[non_exhaustive]
pub enum ForgeEvent {
///RepoRenamed
#[serde(rename = "repoRenamed")]
RepoRenamed {
#[serde(rename = "forgeId")]
forge_id: ForgeId,
from: RepoResource,
to: RepoResource,
},
///RepoTransferred
#[serde(rename = "repoTransferred")]
RepoTransferred {
#[serde(rename = "forgeId")]
forge_id: ForgeId,
from: RepoResource,
to: RepoResource,
},
///RepoCreatedUnmanaged
#[serde(rename = "repoCreatedUnmanaged")]
RepoCreatedUnmanaged {
#[serde(rename = "forgeId")]
forge_id: ForgeId,
resource: RepoResource,
},
///RepoDeleted
#[serde(rename = "repoDeleted")]
RepoDeleted {
#[serde(rename = "forgeId")]
forge_id: ForgeId,
resource: RepoResource,
},
///RoleChanged
#[serde(rename = "roleChanged")]
RoleChanged {
account: ForgeAccount,
#[serde(rename = "forgeId")]
forge_id: ForgeId,
resource: RepoResource,
///The role the account now holds. Absent: the account holds no role now.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
role: ::std::option::Option<ForgeRole>,
},
///ProtectionChanged
#[serde(rename = "protectionChanged")]
ProtectionChanged {
#[serde(rename = "forgeId")]
forge_id: ForgeId,
///Whether the forge still refuses merges without a passing verify-trust check, with no bypass.
#[serde(rename = "requiredCheck")]
required_check: bool,
resource: RepoResource,
},
#[serde(rename = "installationRemoved")]
InstallationRemoved,
///AccountLinked
#[serde(rename = "accountLinked")]
AccountLinked {
account: ForgeAccount,
///The beginAccountLink job.
#[serde(rename = "jobId")]
job_id: JobId,
},
///BindCompleted
#[serde(rename = "bindCompleted")]
BindCompleted {
///The beginBind job.
#[serde(rename = "jobId")]
job_id: JobId,
kind: ForgeEventKind,
///The forge's id for the owner, which survives renames.
#[serde(rename = "ownerId")]
owner_id: ForgeId,
},
}
///`ForgeEventKind`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "enum": [
/// "organization",
/// "user"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum ForgeEventKind {
#[serde(rename = "organization")]
Organization,
#[serde(rename = "user")]
User,
}
impl ::std::fmt::Display for ForgeEventKind {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Organization => f.write_str("organization"),
Self::User => f.write_str("user"),
}
}
}
impl ::std::str::FromStr for ForgeEventKind {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"organization" => Ok(Self::Organization),
"user" => Ok(Self::User),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for ForgeEventKind {
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 ForgeEventKind {
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 ForgeEventKind {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///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())
})
}
}
///A role in the forge's own vocabulary (`maintain`, `write`).
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "A role in the forge's own vocabulary (`maintain`, `write`).",
/// "type": "string",
/// "maxLength": 64,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ForgeRole(::std::string::String);
impl ::std::ops::Deref for ForgeRole {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ForgeRole> for ::std::string::String {
fn from(value: ForgeRole) -> Self {
value.0
}
}
impl ::std::str::FromStr for ForgeRole {
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 ForgeRole {
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 ForgeRole {
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 ForgeRole {
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 ForgeRole {
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 VTC's identifier for a job, unique across the VTC's jobs.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The VTC's identifier for a job, unique across the VTC's jobs.",
/// "type": "string",
/// "maxLength": 128,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct JobId(::std::string::String);
impl ::std::ops::Deref for JobId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<JobId> for ::std::string::String {
fn from(value: JobId) -> Self {
value.0
}
}
impl ::std::str::FromStr for JobId {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 128usize {
return Err("longer than 128 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for JobId {
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 JobId {
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 JobId {
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 JobId {
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 VTC's opaque identifier for a namespace, assigned when it is bound. Stable for the life of the binding; never reused for another binding.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "NamespaceId",
/// "description": "The VTC's opaque identifier for a namespace, assigned when it is bound. Stable for the life of the binding; never reused for another binding.",
/// "type": "string",
/// "maxLength": 128,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct NamespaceId(::std::string::String);
impl ::std::ops::Deref for NamespaceId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<NamespaceId> for ::std::string::String {
fn from(value: NamespaceId) -> Self {
value.0
}
}
impl ::std::str::FromStr for NamespaceId {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 128usize {
return Err("longer than 128 characters".into());
}
if value.chars().count() < 1usize {
return Err("shorter than 1 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for NamespaceId {
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 NamespaceId {
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 NamespaceId {
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 NamespaceId {
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 bridge tells the VTC something happened on the forge — translated from the forge's webhook or found by an inspection sweep — together with any drift it now sees.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/git-ns/bridge/event/0.2",
/// "title": "Payload",
/// "description": "The bridge tells the VTC something happened on the forge — translated from the forge's webhook or found by an inspection sweep — together with any drift it now sees.",
/// "type": "object",
/// "required": [
/// "event",
/// "namespace"
/// ],
/// "properties": {
/// "drift": {
/// "description": "The complete outstanding drift for each repository the event concerns, replacing what the VTC held for those repositories. Absent: the event changes no repository's drift.",
/// "type": "array",
/// "items": {
/// "$ref": "#/definitions/DriftItem"
/// }
/// },
/// "event": {
/// "$ref": "#/definitions/ForgeEvent"
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "namespace": {
/// "description": "The namespace the event happened in.",
/// "$ref": "#/definitions/NamespaceId"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Payload {
///The complete outstanding drift for each repository the event concerns, replacing what the VTC held for those repositories. Absent: the event changes no repository's drift.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub drift: ::std::vec::Vec<DriftItem>,
pub event: ForgeEvent,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///The namespace the event happened in.
pub namespace: NamespaceId,
}
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())
})
}
}
///The VTC has recorded the event. Nothing else is returned.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "The VTC has recorded the event. Nothing else is returned.",
/// "type": "object",
/// "properties": {
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// }
/// },
/// "additionalProperties": false,
/// "$anchor": "response"
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct Response {
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
ext: Default::default(),
}
}
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
/// Types for composing complex structures.
pub mod builder {
#[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 {
drift: ::std::result::Result<::std::vec::Vec<super::DriftItem>, ::std::string::String>,
event: ::std::result::Result<super::ForgeEvent, ::std::string::String>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
namespace: ::std::result::Result<super::NamespaceId, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
drift: Ok(Default::default()),
event: Err("no value supplied for event".to_string()),
ext: Ok(Default::default()),
namespace: Err("no value supplied for namespace".to_string()),
}
}
}
impl Payload {
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 event<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ForgeEvent>,
T::Error: ::std::fmt::Display,
{
self.event = value
.try_into()
.map_err(|e| format!("error converting supplied value for event: {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 namespace<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::NamespaceId>,
T::Error: ::std::fmt::Display,
{
self.namespace = value
.try_into()
.map_err(|e| format!("error converting supplied value for namespace: {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 {
drift: value.drift?,
event: value.event?,
ext: value.ext?,
namespace: value.namespace?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
drift: Ok(value.drift),
event: Ok(value.event),
ext: Ok(value.ext),
namespace: Ok(value.namespace),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
}
}
}
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
}
}
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? })
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self { ext: Ok(value.ext) }
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/git-ns/bridge/event/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 \"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 \"ForgeEvent\": {\n \"description\": \"One forge-neutral event, discriminated by `type`. The specification's event table says what each type means and what the VTC does with it.\",\n \"oneOf\": [\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"forgeId\": {\n \"$ref\": \"#/$defs/ForgeId\"\n },\n \"from\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"to\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"type\": {\n \"const\": \"repoRenamed\"\n }\n },\n \"required\": [\n \"type\",\n \"forgeId\",\n \"from\",\n \"to\"\n ],\n \"title\": \"RepoRenamed\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"forgeId\": {\n \"$ref\": \"#/$defs/ForgeId\"\n },\n \"from\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"to\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"type\": {\n \"const\": \"repoTransferred\"\n }\n },\n \"required\": [\n \"type\",\n \"forgeId\",\n \"from\",\n \"to\"\n ],\n \"title\": \"RepoTransferred\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"forgeId\": {\n \"$ref\": \"#/$defs/ForgeId\"\n },\n \"resource\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"type\": {\n \"const\": \"repoCreatedUnmanaged\"\n }\n },\n \"required\": [\n \"type\",\n \"forgeId\",\n \"resource\"\n ],\n \"title\": \"RepoCreatedUnmanaged\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"forgeId\": {\n \"$ref\": \"#/$defs/ForgeId\"\n },\n \"resource\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"type\": {\n \"const\": \"repoDeleted\"\n }\n },\n \"required\": [\n \"type\",\n \"forgeId\",\n \"resource\"\n ],\n \"title\": \"RepoDeleted\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"account\": {\n \"$ref\": \"#/$defs/ForgeAccount\"\n },\n \"forgeId\": {\n \"$ref\": \"#/$defs/ForgeId\"\n },\n \"resource\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"role\": {\n \"$ref\": \"#/$defs/ForgeRole\",\n \"description\": \"The role the account now holds. Absent: the account holds no role now.\"\n },\n \"type\": {\n \"const\": \"roleChanged\"\n }\n },\n \"required\": [\n \"type\",\n \"forgeId\",\n \"resource\",\n \"account\"\n ],\n \"title\": \"RoleChanged\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"forgeId\": {\n \"$ref\": \"#/$defs/ForgeId\"\n },\n \"requiredCheck\": {\n \"description\": \"Whether the forge still refuses merges without a passing verify-trust check, with no bypass.\",\n \"type\": \"boolean\"\n },\n \"resource\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"type\": {\n \"const\": \"protectionChanged\"\n }\n },\n \"required\": [\n \"type\",\n \"forgeId\",\n \"resource\",\n \"requiredCheck\"\n ],\n \"title\": \"ProtectionChanged\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"type\": {\n \"const\": \"installationRemoved\"\n }\n },\n \"required\": [\n \"type\"\n ],\n \"title\": \"InstallationRemoved\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"account\": {\n \"$ref\": \"#/$defs/ForgeAccount\"\n },\n \"jobId\": {\n \"$ref\": \"#/$defs/JobId\",\n \"description\": \"The beginAccountLink job.\"\n },\n \"type\": {\n \"const\": \"accountLinked\"\n }\n },\n \"required\": [\n \"type\",\n \"jobId\",\n \"account\"\n ],\n \"title\": \"AccountLinked\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"jobId\": {\n \"$ref\": \"#/$defs/JobId\",\n \"description\": \"The beginBind job.\"\n },\n \"kind\": {\n \"enum\": [\n \"organization\",\n \"user\"\n ],\n \"type\": \"string\"\n },\n \"ownerId\": {\n \"$ref\": \"#/$defs/ForgeId\",\n \"description\": \"The forge's id for the owner, which survives renames.\"\n },\n \"type\": {\n \"const\": \"bindCompleted\"\n }\n },\n \"required\": [\n \"type\",\n \"jobId\",\n \"ownerId\",\n \"kind\"\n ],\n \"title\": \"BindCompleted\",\n \"type\": \"object\"\n }\n ],\n \"title\": \"ForgeEvent\",\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 \"ForgeRole\": {\n \"description\": \"A role in the forge's own vocabulary (`maintain`, `write`).\",\n \"maxLength\": 64,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"JobId\": {\n \"description\": \"The VTC's identifier for a job, unique across the VTC's jobs.\",\n \"maxLength\": 128,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"NamespaceId\": {\n \"description\": \"The VTC's opaque identifier for a namespace, assigned when it is bound. Stable for the life of the binding; never reused for another binding.\",\n \"maxLength\": 128,\n \"minLength\": 1,\n \"title\": \"NamespaceId\",\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 \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"The VTC has recorded the event. Nothing else is returned.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n }\n },\n \"required\": [],\n \"title\": \"Git Namespaces — Bridge Event — response payload\",\n \"type\": \"object\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/git-ns/bridge/event/0.2\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"The bridge tells the VTC something happened on the forge — translated from the forge's webhook or found by an inspection sweep — together with any drift it now sees.\",\n \"properties\": {\n \"drift\": {\n \"description\": \"The complete outstanding drift for each repository the event concerns, replacing what the VTC held for those repositories. Absent: the event changes no repository's drift.\",\n \"items\": {\n \"$ref\": \"#/$defs/DriftItem\"\n },\n \"type\": \"array\"\n },\n \"event\": {\n \"$ref\": \"#/$defs/ForgeEvent\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"namespace\": {\n \"$ref\": \"#/$defs/NamespaceId\",\n \"description\": \"The namespace the event happened in.\"\n }\n },\n \"required\": [\n \"namespace\",\n \"event\"\n ],\n \"title\": \"Git Namespaces — Bridge Event — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/git-ns/bridge/event/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 \"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 \"ForgeEvent\": {\n \"description\": \"One forge-neutral event, discriminated by `type`. The specification's event table says what each type means and what the VTC does with it.\",\n \"oneOf\": [\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"forgeId\": {\n \"$ref\": \"#/$defs/ForgeId\"\n },\n \"from\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"to\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"type\": {\n \"const\": \"repoRenamed\"\n }\n },\n \"required\": [\n \"type\",\n \"forgeId\",\n \"from\",\n \"to\"\n ],\n \"title\": \"RepoRenamed\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"forgeId\": {\n \"$ref\": \"#/$defs/ForgeId\"\n },\n \"from\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"to\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"type\": {\n \"const\": \"repoTransferred\"\n }\n },\n \"required\": [\n \"type\",\n \"forgeId\",\n \"from\",\n \"to\"\n ],\n \"title\": \"RepoTransferred\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"forgeId\": {\n \"$ref\": \"#/$defs/ForgeId\"\n },\n \"resource\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"type\": {\n \"const\": \"repoCreatedUnmanaged\"\n }\n },\n \"required\": [\n \"type\",\n \"forgeId\",\n \"resource\"\n ],\n \"title\": \"RepoCreatedUnmanaged\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"forgeId\": {\n \"$ref\": \"#/$defs/ForgeId\"\n },\n \"resource\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"type\": {\n \"const\": \"repoDeleted\"\n }\n },\n \"required\": [\n \"type\",\n \"forgeId\",\n \"resource\"\n ],\n \"title\": \"RepoDeleted\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"account\": {\n \"$ref\": \"#/$defs/ForgeAccount\"\n },\n \"forgeId\": {\n \"$ref\": \"#/$defs/ForgeId\"\n },\n \"resource\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"role\": {\n \"$ref\": \"#/$defs/ForgeRole\",\n \"description\": \"The role the account now holds. Absent: the account holds no role now.\"\n },\n \"type\": {\n \"const\": \"roleChanged\"\n }\n },\n \"required\": [\n \"type\",\n \"forgeId\",\n \"resource\",\n \"account\"\n ],\n \"title\": \"RoleChanged\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"forgeId\": {\n \"$ref\": \"#/$defs/ForgeId\"\n },\n \"requiredCheck\": {\n \"description\": \"Whether the forge still refuses merges without a passing verify-trust check, with no bypass.\",\n \"type\": \"boolean\"\n },\n \"resource\": {\n \"$ref\": \"#/$defs/RepoResource\"\n },\n \"type\": {\n \"const\": \"protectionChanged\"\n }\n },\n \"required\": [\n \"type\",\n \"forgeId\",\n \"resource\",\n \"requiredCheck\"\n ],\n \"title\": \"ProtectionChanged\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"type\": {\n \"const\": \"installationRemoved\"\n }\n },\n \"required\": [\n \"type\"\n ],\n \"title\": \"InstallationRemoved\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"account\": {\n \"$ref\": \"#/$defs/ForgeAccount\"\n },\n \"jobId\": {\n \"$ref\": \"#/$defs/JobId\",\n \"description\": \"The beginAccountLink job.\"\n },\n \"type\": {\n \"const\": \"accountLinked\"\n }\n },\n \"required\": [\n \"type\",\n \"jobId\",\n \"account\"\n ],\n \"title\": \"AccountLinked\",\n \"type\": \"object\"\n },\n {\n \"additionalProperties\": false,\n \"properties\": {\n \"jobId\": {\n \"$ref\": \"#/$defs/JobId\",\n \"description\": \"The beginBind job.\"\n },\n \"kind\": {\n \"enum\": [\n \"organization\",\n \"user\"\n ],\n \"type\": \"string\"\n },\n \"ownerId\": {\n \"$ref\": \"#/$defs/ForgeId\",\n \"description\": \"The forge's id for the owner, which survives renames.\"\n },\n \"type\": {\n \"const\": \"bindCompleted\"\n }\n },\n \"required\": [\n \"type\",\n \"jobId\",\n \"ownerId\",\n \"kind\"\n ],\n \"title\": \"BindCompleted\",\n \"type\": \"object\"\n }\n ],\n \"title\": \"ForgeEvent\",\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 \"ForgeRole\": {\n \"description\": \"A role in the forge's own vocabulary (`maintain`, `write`).\",\n \"maxLength\": 64,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"JobId\": {\n \"description\": \"The VTC's identifier for a job, unique across the VTC's jobs.\",\n \"maxLength\": 128,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"NamespaceId\": {\n \"description\": \"The VTC's opaque identifier for a namespace, assigned when it is bound. Stable for the life of the binding; never reused for another binding.\",\n \"maxLength\": 128,\n \"minLength\": 1,\n \"title\": \"NamespaceId\",\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 \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"The VTC has recorded the event. Nothing else is returned.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n }\n },\n \"required\": [],\n \"title\": \"Git Namespaces — Bridge Event — response payload\",\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_NAMESPACE];
/// 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:unknownNamespace`
///
/// No namespace bound to this VTC has this identifier, or contains this resource.
///
/// Declared `retryable: false`.
pub const UNKNOWN_NAMESPACE: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "git-ns:unknownNamespace",
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).
#[test]
fn request_example_1() {
const JSON: &str = "{\n \"id\": \"urn:uuid:a98c01fe-2fd9-457d-ac53-a7900258b001\",\n \"type\": \"https://trusttasks.org/spec/git-ns/bridge/event/0.2\",\n \"threadId\": \"urn:uuid:a98c01fe-2fd9-457d-ac53-a7900258b001\",\n \"issuer\": \"did:webvh:QmBridgeScid5:bridge.acme-vtc.example\",\n \"recipient\": \"did:webvh:QmVtcScid7:acme-vtc.example\",\n \"issuedAt\": \"2026-10-02T14:20:00Z\",\n \"payload\": {\n \"namespace\": \"ns_01J8Z6Q4M2\",\n \"event\": {\n \"type\": \"repoRenamed\",\n \"forgeId\": \"812736451\",\n \"from\": \"github.com/acme/widgets\",\n \"to\": \"github.com/acme/widgets-core\"\n }\n },\n \"proof\": {\n \"type\": \"DataIntegrityProof\",\n \"cryptosuite\": \"eddsa-jcs-2022\",\n \"verificationMethod\": \"did:webvh:QmBridgeScid5:bridge.acme-vtc.example#key-1\",\n \"created\": \"2026-10-02T14:20:00Z\",\n \"proofPurpose\": \"authentication\",\n \"proofValue\": \"zX1BNqDY7HHzMVndp638Ye2Qw7s2xvZVrfbz7ZvnMWvVZHKJ1EEQHyUQGNwEB5ZhAzpCNYXntvAbAmk5tm46YaN\"\n }\n}\n";
let doc: crate::TrustTask<super::Payload> =
serde_json::from_str(JSON).expect("deserialize request example");
let rendered = serde_json::to_value(&doc).expect("re-serialize");
let expected: serde_json::Value = serde_json::from_str(JSON).expect("re-parse expected");
assert_eq!(rendered, expected, "request example failed round-trip");
}
#[test]
fn request_example_2() {
const JSON: &str = "{\n \"id\": \"urn:uuid:a98c01fe-2fd9-457d-ac53-a7900258b007\",\n \"type\": \"https://trusttasks.org/spec/git-ns/bridge/event/0.2\",\n \"threadId\": \"urn:uuid:a98c01fe-2fd9-457d-ac53-a7900258b007\",\n \"issuer\": \"did:webvh:QmBridgeScid5:bridge.acme-vtc.example\",\n \"recipient\": \"did:webvh:QmVtcScid7:acme-vtc.example\",\n \"issuedAt\": \"2026-10-05T11:00:00Z\",\n \"payload\": {\n \"namespace\": \"ns_01J8Z6Q4M2\",\n \"event\": {\n \"type\": \"repoTransferred\",\n \"forgeId\": \"812736990\",\n \"from\": \"github.com/acme/gadgets\",\n \"to\": \"github.com/acme-labs/gadgets\"\n }\n },\n \"proof\": {\n \"type\": \"DataIntegrityProof\",\n \"cryptosuite\": \"eddsa-jcs-2022\",\n \"verificationMethod\": \"did:webvh:QmBridgeScid5:bridge.acme-vtc.example#key-1\",\n \"created\": \"2026-10-05T11:00:00Z\",\n \"proofPurpose\": \"authentication\",\n \"proofValue\": \"z4Tn8Wq2Lb6Rx1Kc9Hm3Fd7Ya5Js2Vg8Ue4Zo1Ti6Pn3Xb9Cq5Dw2Ek7Sh4Gv1Ly8Au6Bj3Kf9Tr2Np5Zm7Rc\"\n }\n}\n";
let doc: crate::TrustTask<super::Payload> =
serde_json::from_str(JSON).expect("deserialize request example");
let rendered = serde_json::to_value(&doc).expect("re-serialize");
let expected: serde_json::Value = serde_json::from_str(JSON).expect("re-parse expected");
assert_eq!(rendered, expected, "request example failed round-trip");
}
#[test]
fn request_example_3() {
const JSON: &str = "{\n \"id\": \"urn:uuid:a98c01fe-2fd9-457d-ac53-a7900258b003\",\n \"type\": \"https://trusttasks.org/spec/git-ns/bridge/event/0.2\",\n \"threadId\": \"urn:uuid:a98c01fe-2fd9-457d-ac53-a7900258b003\",\n \"issuer\": \"did:webvh:QmBridgeScid5:bridge.acme-vtc.example\",\n \"recipient\": \"did:webvh:QmVtcScid7:acme-vtc.example\",\n \"issuedAt\": \"2026-10-03T08:00:00Z\",\n \"payload\": {\n \"namespace\": \"ns_01J8Z6Q4M2\",\n \"event\": {\n \"type\": \"protectionChanged\",\n \"forgeId\": \"812736990\",\n \"resource\": \"github.com/acme/gadgets\",\n \"requiredCheck\": false\n },\n \"drift\": [\n {\n \"type\": \"requiredCheckMissing\",\n \"resource\": \"github.com/acme/gadgets\",\n \"observed\": \"Verify commit trust: not required\",\n \"expected\": \"Verify commit trust: required\"\n }\n ]\n },\n \"proof\": {\n \"type\": \"DataIntegrityProof\",\n \"cryptosuite\": \"eddsa-jcs-2022\",\n \"verificationMethod\": \"did:webvh:QmBridgeScid5:bridge.acme-vtc.example#key-1\",\n \"created\": \"2026-10-03T08:00:00Z\",\n \"proofPurpose\": \"authentication\",\n \"proofValue\": \"zLKQi5maEpU3bgPaMfECN14do9qszZbcEDatyWhNH5es3Pc9UYi5jmbZ7AsPdE5TQEeoj8LcV5BBYY8w3s78nVS\"\n }\n}\n";
let doc: crate::TrustTask<super::Payload> =
serde_json::from_str(JSON).expect("deserialize request example");
let rendered = serde_json::to_value(&doc).expect("re-serialize");
let expected: serde_json::Value = serde_json::from_str(JSON).expect("re-parse expected");
assert_eq!(rendered, expected, "request example failed round-trip");
}
#[test]
fn request_example_4() {
const JSON: &str = "{\n \"id\": \"urn:uuid:a98c01fe-2fd9-457d-ac53-a7900258b005\",\n \"type\": \"https://trusttasks.org/spec/git-ns/bridge/event/0.2\",\n \"threadId\": \"urn:uuid:a98c01fe-2fd9-457d-ac53-a7900258b005\",\n \"issuer\": \"did:webvh:QmBridgeScid5:bridge.acme-vtc.example\",\n \"recipient\": \"did:webvh:QmVtcScid7:acme-vtc.example\",\n \"issuedAt\": \"2026-09-23T10:03:00Z\",\n \"payload\": {\n \"namespace\": \"ns_01J8Z6Q4M2\",\n \"event\": {\n \"type\": \"bindCompleted\",\n \"jobId\": \"job_01J8Z6Q4N0\",\n \"ownerId\": \"91827364\",\n \"kind\": \"organization\"\n }\n },\n \"proof\": {\n \"type\": \"DataIntegrityProof\",\n \"cryptosuite\": \"eddsa-jcs-2022\",\n \"verificationMethod\": \"did:webvh:QmBridgeScid5:bridge.acme-vtc.example#key-1\",\n \"created\": \"2026-09-23T10:03:00Z\",\n \"proofPurpose\": \"authentication\",\n \"proofValue\": \"zErKBa1j26x1aicAi862KvPr5RvRvFaKU5EtMUicEE6BTmNsRMLKgPP6sMorj7tM5Kx2rKHE7KV73KziML7f9Vb\"\n }\n}\n";
let doc: crate::TrustTask<super::Payload> =
serde_json::from_str(JSON).expect("deserialize request example");
let rendered = serde_json::to_value(&doc).expect("re-serialize");
let expected: serde_json::Value = serde_json::from_str(JSON).expect("re-parse expected");
assert_eq!(rendered, expected, "request example failed round-trip");
}
#[test]
fn response_example_1() {
const JSON: &str = "{\n \"id\": \"urn:uuid:a98c01fe-2fd9-457d-ac53-a7900258b002\",\n \"type\": \"https://trusttasks.org/spec/git-ns/bridge/event/0.2#response\",\n \"threadId\": \"urn:uuid:a98c01fe-2fd9-457d-ac53-a7900258b001\",\n \"issuer\": \"did:webvh:QmVtcScid7:acme-vtc.example\",\n \"recipient\": \"did:webvh:QmBridgeScid5:bridge.acme-vtc.example\",\n \"issuedAt\": \"2026-10-02T14:20:01Z\",\n \"payload\": {},\n \"proof\": {\n \"type\": \"DataIntegrityProof\",\n \"cryptosuite\": \"eddsa-jcs-2022\",\n \"verificationMethod\": \"did:webvh:QmVtcScid7:acme-vtc.example#key-1\",\n \"created\": \"2026-10-02T14:20:01Z\",\n \"proofPurpose\": \"authentication\",\n \"proofValue\": \"z5mPrASQ5cpsmsQik4scivNBxCv1fJCdQq7sNCvHL7XE4AHMMM4Emo86yAL6DnBDwF1PdKfcgz9bf6nKXS2KHh1\"\n }\n}\n";
let doc: crate::TrustTask<super::Response> =
serde_json::from_str(JSON).expect("deserialize response example");
let rendered = serde_json::to_value(&doc).expect("re-serialize");
let expected: serde_json::Value = serde_json::from_str(JSON).expect("re-parse expected");
assert_eq!(rendered, expected, "response example failed round-trip");
}
/// 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)] = &[
(
"`event.type` is one of the nine forge-neutral types; forge webhook names are translated, never forwarded.",
"{\n \"event\": {\n \"forgeId\": \"1\",\n \"type\": \"repository.renamed\"\n },\n \"namespace\": \"ns_1\"\n}",
),
(
"A rename names both resources.",
"{\n \"event\": {\n \"forgeId\": \"1\",\n \"to\": \"github.com/acme/new\",\n \"type\": \"repoRenamed\"\n },\n \"namespace\": \"ns_1\"\n}",
),
(
"`event` is required.",
"{\n \"drift\": [],\n \"namespace\": \"ns_1\"\n}",
),
(
"A drift item's type is one of the drift types.",
"{\n \"drift\": [\n {\n \"resource\": \"github.com/acme/widgets\",\n \"type\": \"somethingOdd\"\n }\n ],\n \"event\": {\n \"type\": \"installationRemoved\"\n },\n \"namespace\": \"ns_1\"\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
);
}
}
}