//! Generated by `trust-tasks-codegen` — do not edit by hand.
//!
//! Spec slug: `git-ns/bridge/result`. Version: `0.1`.
#[allow(unused_imports)]
use serde::{Deserialize, Serialize};
/// Error types.
pub mod error {
/// Error from a `TryFrom` or `FromStr` implementation.
pub struct ConversionError(::std::borrow::Cow<'static, str>);
impl ::std::error::Error for ConversionError {}
impl ::std::fmt::Display for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Display::fmt(&self.0, f)
}
}
impl ::std::fmt::Debug for ConversionError {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> Result<(), ::std::fmt::Error> {
::std::fmt::Debug::fmt(&self.0, f)
}
}
impl From<&'static str> for ConversionError {
fn from(value: &'static str) -> Self {
Self(value.into())
}
}
impl From<String> for ConversionError {
fn from(value: String) -> Self {
Self(value.into())
}
}
}
///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())
})
}
}
///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())
})
}
}
///The bridge reports how a job ended. Exactly one result is sent per job; the VTC updates the repository's state, bootstrap status and forge id from it.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "$id": "https://trusttasks.org/spec/git-ns/bridge/result/0.1",
/// "title": "Payload",
/// "description": "The bridge reports how a job ended. Exactly one result is sent per job; the VTC updates the repository's state, bootstrap status and forge id from it.",
/// "type": "object",
/// "required": [
/// "jobId",
/// "outcome"
/// ],
/// "properties": {
/// "error": {
/// "description": "Why the job failed or stopped partway. Present when `outcome` is not `succeeded`.",
/// "type": "object",
/// "required": [
/// "code"
/// ],
/// "properties": {
/// "code": {
/// "description": "Forge-neutral: `nameTaken`, `notFound`, `forbidden` (the bridge's forge credentials lack a permission), `notCapable` (this forge or namespace cannot do it), `rateLimited`, `expired` (a begin* job's person never completed it), `forgeError`. A bridge MAY use others.",
/// "type": "string",
/// "maxLength": 64,
/// "minLength": 1,
/// "pattern": "^[a-z][A-Za-z0-9]*$"
/// },
/// "message": {
/// "type": "string",
/// "maxLength": 1024
/// }
/// },
/// "additionalProperties": false
/// },
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "jobId": {
/// "description": "The job, as git-ns/bridge/job named it.",
/// "type": "string",
/// "maxLength": 128,
/// "minLength": 1
/// },
/// "outcome": {
/// "description": "`succeeded` — every step was applied. `failed` — nothing was applied. `partial` — some steps were applied and at least one failed; `steps` says which. Every step is check-then-apply, so the VTC may send the job again.",
/// "type": "string",
/// "enum": [
/// "succeeded",
/// "failed",
/// "partial"
/// ]
/// },
/// "repo": {
/// "description": "The repository the job touched, as the forge now reports it. Present whenever the job reached a repository.",
/// "type": "object",
/// "required": [
/// "forgeId",
/// "resource"
/// ],
/// "properties": {
/// "forgeId": {
/// "$ref": "#/definitions/ForgeId"
/// },
/// "resource": {
/// "$ref": "#/definitions/RepoResource"
/// }
/// },
/// "additionalProperties": false
/// },
/// "steps": {
/// "description": "Per-step outcomes, in the order they ran.",
/// "type": "array",
/// "items": {
/// "type": "object",
/// "required": [
/// "outcome",
/// "step"
/// ],
/// "properties": {
/// "detail": {
/// "description": "Human-readable detail, typically for a failure.",
/// "type": "string",
/// "maxLength": 1024
/// },
/// "outcome": {
/// "description": "`applied` — changed the forge. `unchanged` — already as required. `failed` — could not be applied. `skipped` — not attempted because an earlier step failed.",
/// "type": "string",
/// "enum": [
/// "applied",
/// "unchanged",
/// "failed",
/// "skipped"
/// ]
/// },
/// "step": {
/// "description": "The step name, from the adapter's plan.",
/// "type": "string",
/// "maxLength": 64,
/// "minLength": 1,
/// "pattern": "^[a-z][A-Za-z0-9]*$"
/// }
/// },
/// "additionalProperties": false
/// }
/// }
/// },
/// "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 error: ::std::option::Option<PayloadError>,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub ext: ::std::option::Option<Ext>,
///The job, as git-ns/bridge/job named it.
#[serde(rename = "jobId")]
pub job_id: PayloadJobId,
///`succeeded` — every step was applied. `failed` — nothing was applied. `partial` — some steps were applied and at least one failed; `steps` says which. Every step is check-then-apply, so the VTC may send the job again.
pub outcome: PayloadOutcome,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub repo: ::std::option::Option<PayloadRepo>,
///Per-step outcomes, in the order they ran.
#[serde(default, skip_serializing_if = "::std::vec::Vec::is_empty")]
pub steps: ::std::vec::Vec<PayloadStepsItem>,
}
impl Payload {
pub fn builder() -> builder::Payload {
Default::default()
}
}
///Why the job failed or stopped partway. Present when `outcome` is not `succeeded`.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Why the job failed or stopped partway. Present when `outcome` is not `succeeded`.",
/// "type": "object",
/// "required": [
/// "code"
/// ],
/// "properties": {
/// "code": {
/// "description": "Forge-neutral: `nameTaken`, `notFound`, `forbidden` (the bridge's forge credentials lack a permission), `notCapable` (this forge or namespace cannot do it), `rateLimited`, `expired` (a begin* job's person never completed it), `forgeError`. A bridge MAY use others.",
/// "type": "string",
/// "maxLength": 64,
/// "minLength": 1,
/// "pattern": "^[a-z][A-Za-z0-9]*$"
/// },
/// "message": {
/// "type": "string",
/// "maxLength": 1024
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct PayloadError {
///Forge-neutral: `nameTaken`, `notFound`, `forbidden` (the bridge's forge credentials lack a permission), `notCapable` (this forge or namespace cannot do it), `rateLimited`, `expired` (a begin* job's person never completed it), `forgeError`. A bridge MAY use others.
pub code: PayloadErrorCode,
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub message: ::std::option::Option<PayloadErrorMessage>,
}
impl PayloadError {
pub fn builder() -> builder::PayloadError {
Default::default()
}
}
///Forge-neutral: `nameTaken`, `notFound`, `forbidden` (the bridge's forge credentials lack a permission), `notCapable` (this forge or namespace cannot do it), `rateLimited`, `expired` (a begin* job's person never completed it), `forgeError`. A bridge MAY use others.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Forge-neutral: `nameTaken`, `notFound`, `forbidden` (the bridge's forge credentials lack a permission), `notCapable` (this forge or namespace cannot do it), `rateLimited`, `expired` (a begin* job's person never completed it), `forgeError`. A bridge MAY use others.",
/// "type": "string",
/// "maxLength": 64,
/// "minLength": 1,
/// "pattern": "^[a-z][A-Za-z0-9]*$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadErrorCode(::std::string::String);
impl ::std::ops::Deref for PayloadErrorCode {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadErrorCode> for ::std::string::String {
fn from(value: PayloadErrorCode) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadErrorCode {
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());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| ::regress::Regex::new("^[a-z][A-Za-z0-9]*$").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[a-z][A-Za-z0-9]*$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadErrorCode {
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 PayloadErrorCode {
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 PayloadErrorCode {
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 PayloadErrorCode {
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())
})
}
}
///`PayloadErrorMessage`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 1024
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadErrorMessage(::std::string::String);
impl ::std::ops::Deref for PayloadErrorMessage {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadErrorMessage> for ::std::string::String {
fn from(value: PayloadErrorMessage) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadErrorMessage {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 1024usize {
return Err("longer than 1024 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadErrorMessage {
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 PayloadErrorMessage {
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 PayloadErrorMessage {
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 PayloadErrorMessage {
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 job, as git-ns/bridge/job named it.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The job, as git-ns/bridge/job named it.",
/// "type": "string",
/// "maxLength": 128,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadJobId(::std::string::String);
impl ::std::ops::Deref for PayloadJobId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadJobId> for ::std::string::String {
fn from(value: PayloadJobId) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadJobId {
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 PayloadJobId {
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 PayloadJobId {
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 PayloadJobId {
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 PayloadJobId {
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())
})
}
}
///`succeeded` — every step was applied. `failed` — nothing was applied. `partial` — some steps were applied and at least one failed; `steps` says which. Every step is check-then-apply, so the VTC may send the job again.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "`succeeded` — every step was applied. `failed` — nothing was applied. `partial` — some steps were applied and at least one failed; `steps` says which. Every step is check-then-apply, so the VTC may send the job again.",
/// "type": "string",
/// "enum": [
/// "succeeded",
/// "failed",
/// "partial"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum PayloadOutcome {
#[serde(rename = "succeeded")]
Succeeded,
#[serde(rename = "failed")]
Failed,
#[serde(rename = "partial")]
Partial,
}
impl ::std::fmt::Display for PayloadOutcome {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Succeeded => f.write_str("succeeded"),
Self::Failed => f.write_str("failed"),
Self::Partial => f.write_str("partial"),
}
}
}
impl ::std::str::FromStr for PayloadOutcome {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"succeeded" => Ok(Self::Succeeded),
"failed" => Ok(Self::Failed),
"partial" => Ok(Self::Partial),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for PayloadOutcome {
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 PayloadOutcome {
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 PayloadOutcome {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///The repository the job touched, as the forge now reports it. Present whenever the job reached a repository.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The repository the job touched, as the forge now reports it. Present whenever the job reached a repository.",
/// "type": "object",
/// "required": [
/// "forgeId",
/// "resource"
/// ],
/// "properties": {
/// "forgeId": {
/// "$ref": "#/definitions/ForgeId"
/// },
/// "resource": {
/// "$ref": "#/definitions/RepoResource"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct PayloadRepo {
#[serde(rename = "forgeId")]
pub forge_id: ForgeId,
pub resource: RepoResource,
}
impl PayloadRepo {
pub fn builder() -> builder::PayloadRepo {
Default::default()
}
}
///`PayloadStepsItem`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "object",
/// "required": [
/// "outcome",
/// "step"
/// ],
/// "properties": {
/// "detail": {
/// "description": "Human-readable detail, typically for a failure.",
/// "type": "string",
/// "maxLength": 1024
/// },
/// "outcome": {
/// "description": "`applied` — changed the forge. `unchanged` — already as required. `failed` — could not be applied. `skipped` — not attempted because an earlier step failed.",
/// "type": "string",
/// "enum": [
/// "applied",
/// "unchanged",
/// "failed",
/// "skipped"
/// ]
/// },
/// "step": {
/// "description": "The step name, from the adapter's plan.",
/// "type": "string",
/// "maxLength": 64,
/// "minLength": 1,
/// "pattern": "^[a-z][A-Za-z0-9]*$"
/// }
/// },
/// "additionalProperties": false
///}
/// ```
/// </details>
#[derive(::serde::Deserialize, ::serde::Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
#[non_exhaustive]
pub struct PayloadStepsItem {
///Human-readable detail, typically for a failure.
#[serde(default, skip_serializing_if = "::std::option::Option::is_none")]
pub detail: ::std::option::Option<PayloadStepsItemDetail>,
///`applied` — changed the forge. `unchanged` — already as required. `failed` — could not be applied. `skipped` — not attempted because an earlier step failed.
pub outcome: PayloadStepsItemOutcome,
///The step name, from the adapter's plan.
pub step: PayloadStepsItemStep,
}
impl PayloadStepsItem {
pub fn builder() -> builder::PayloadStepsItem {
Default::default()
}
}
///Human-readable detail, typically for a failure.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "Human-readable detail, typically for a failure.",
/// "type": "string",
/// "maxLength": 1024
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadStepsItemDetail(::std::string::String);
impl ::std::ops::Deref for PayloadStepsItemDetail {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadStepsItemDetail> for ::std::string::String {
fn from(value: PayloadStepsItemDetail) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadStepsItemDetail {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
if value.chars().count() > 1024usize {
return Err("longer than 1024 characters".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadStepsItemDetail {
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 PayloadStepsItemDetail {
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 PayloadStepsItemDetail {
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 PayloadStepsItemDetail {
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())
})
}
}
///`applied` — changed the forge. `unchanged` — already as required. `failed` — could not be applied. `skipped` — not attempted because an earlier step failed.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "`applied` — changed the forge. `unchanged` — already as required. `failed` — could not be applied. `skipped` — not attempted because an earlier step failed.",
/// "type": "string",
/// "enum": [
/// "applied",
/// "unchanged",
/// "failed",
/// "skipped"
/// ]
///}
/// ```
/// </details>
#[derive(
::serde::Deserialize,
::serde::Serialize,
Clone,
Copy,
Debug,
Eq,
Hash,
Ord,
PartialEq,
PartialOrd,
)]
#[non_exhaustive]
pub enum PayloadStepsItemOutcome {
#[serde(rename = "applied")]
Applied,
#[serde(rename = "unchanged")]
Unchanged,
#[serde(rename = "failed")]
Failed,
#[serde(rename = "skipped")]
Skipped,
}
impl ::std::fmt::Display for PayloadStepsItemOutcome {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
match *self {
Self::Applied => f.write_str("applied"),
Self::Unchanged => f.write_str("unchanged"),
Self::Failed => f.write_str("failed"),
Self::Skipped => f.write_str("skipped"),
}
}
}
impl ::std::str::FromStr for PayloadStepsItemOutcome {
type Err = self::error::ConversionError;
fn from_str(value: &str) -> ::std::result::Result<Self, self::error::ConversionError> {
match value {
"applied" => Ok(Self::Applied),
"unchanged" => Ok(Self::Unchanged),
"failed" => Ok(Self::Failed),
"skipped" => Ok(Self::Skipped),
_ => Err("invalid value".into()),
}
}
}
impl ::std::convert::TryFrom<&str> for PayloadStepsItemOutcome {
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 PayloadStepsItemOutcome {
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 PayloadStepsItemOutcome {
type Error = self::error::ConversionError;
fn try_from(
value: ::std::string::String,
) -> ::std::result::Result<Self, self::error::ConversionError> {
value.parse()
}
}
///The step name, from the adapter's plan.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "description": "The step name, from the adapter's plan.",
/// "type": "string",
/// "maxLength": 64,
/// "minLength": 1,
/// "pattern": "^[a-z][A-Za-z0-9]*$"
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct PayloadStepsItemStep(::std::string::String);
impl ::std::ops::Deref for PayloadStepsItemStep {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<PayloadStepsItemStep> for ::std::string::String {
fn from(value: PayloadStepsItemStep) -> Self {
value.0
}
}
impl ::std::str::FromStr for PayloadStepsItemStep {
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());
}
static PATTERN: ::std::sync::LazyLock<::regress::Regex> =
::std::sync::LazyLock::new(|| ::regress::Regex::new("^[a-z][A-Za-z0-9]*$").unwrap());
if PATTERN.find(value).is_none() {
return Err("doesn't match pattern \"^[a-z][A-Za-z0-9]*$\"".into());
}
Ok(Self(value.to_string()))
}
}
impl ::std::convert::TryFrom<&str> for PayloadStepsItemStep {
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 PayloadStepsItemStep {
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 PayloadStepsItemStep {
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 PayloadStepsItemStep {
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 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 result.
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "title": "Response",
/// "description": "The VTC has recorded the result.",
/// "type": "object",
/// "required": [
/// "jobId"
/// ],
/// "properties": {
/// "ext": {
/// "$ref": "#/definitions/Ext"
/// },
/// "jobId": {
/// "type": "string",
/// "maxLength": 128,
/// "minLength": 1
/// }
/// },
/// "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>,
#[serde(rename = "jobId")]
pub job_id: ResponseJobId,
}
impl Response {
pub fn builder() -> builder::Response {
Default::default()
}
}
///`ResponseJobId`
///
/// <details><summary>JSON schema</summary>
///
/// ```json
///{
/// "type": "string",
/// "maxLength": 128,
/// "minLength": 1
///}
/// ```
/// </details>
#[derive(::serde::Serialize, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[serde(transparent)]
pub struct ResponseJobId(::std::string::String);
impl ::std::ops::Deref for ResponseJobId {
type Target = ::std::string::String;
fn deref(&self) -> &::std::string::String {
&self.0
}
}
impl ::std::convert::From<ResponseJobId> for ::std::string::String {
fn from(value: ResponseJobId) -> Self {
value.0
}
}
impl ::std::str::FromStr for ResponseJobId {
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 ResponseJobId {
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 ResponseJobId {
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 ResponseJobId {
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 ResponseJobId {
fn deserialize<D>(deserializer: D) -> ::std::result::Result<Self, D::Error>
where
D: ::serde::Deserializer<'de>,
{
::std::string::String::deserialize(deserializer)?
.parse()
.map_err(|e: self::error::ConversionError| {
<D::Error as ::serde::de::Error>::custom(e.to_string())
})
}
}
/// Types for composing complex structures.
pub mod builder {
#[derive(Clone, Debug)]
pub struct Payload {
error: ::std::result::Result<
::std::option::Option<super::PayloadError>,
::std::string::String,
>,
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
job_id: ::std::result::Result<super::PayloadJobId, ::std::string::String>,
outcome: ::std::result::Result<super::PayloadOutcome, ::std::string::String>,
repo:
::std::result::Result<::std::option::Option<super::PayloadRepo>, ::std::string::String>,
steps:
::std::result::Result<::std::vec::Vec<super::PayloadStepsItem>, ::std::string::String>,
}
impl ::std::default::Default for Payload {
fn default() -> Self {
Self {
error: Ok(Default::default()),
ext: Ok(Default::default()),
job_id: Err("no value supplied for job_id".to_string()),
outcome: Err("no value supplied for outcome".to_string()),
repo: Ok(Default::default()),
steps: Ok(Default::default()),
}
}
}
impl Payload {
pub fn error<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadError>>,
T::Error: ::std::fmt::Display,
{
self.error = value
.try_into()
.map_err(|e| format!("error converting supplied value for error: {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 job_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadJobId>,
T::Error: ::std::fmt::Display,
{
self.job_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for job_id: {e}"));
self
}
pub fn outcome<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadOutcome>,
T::Error: ::std::fmt::Display,
{
self.outcome = value
.try_into()
.map_err(|e| format!("error converting supplied value for outcome: {e}"));
self
}
pub fn repo<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadRepo>>,
T::Error: ::std::fmt::Display,
{
self.repo = value
.try_into()
.map_err(|e| format!("error converting supplied value for repo: {e}"));
self
}
pub fn steps<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::vec::Vec<super::PayloadStepsItem>>,
T::Error: ::std::fmt::Display,
{
self.steps = value
.try_into()
.map_err(|e| format!("error converting supplied value for steps: {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 {
error: value.error?,
ext: value.ext?,
job_id: value.job_id?,
outcome: value.outcome?,
repo: value.repo?,
steps: value.steps?,
})
}
}
impl ::std::convert::From<super::Payload> for Payload {
fn from(value: super::Payload) -> Self {
Self {
error: Ok(value.error),
ext: Ok(value.ext),
job_id: Ok(value.job_id),
outcome: Ok(value.outcome),
repo: Ok(value.repo),
steps: Ok(value.steps),
}
}
}
#[derive(Clone, Debug)]
pub struct PayloadError {
code: ::std::result::Result<super::PayloadErrorCode, ::std::string::String>,
message: ::std::result::Result<
::std::option::Option<super::PayloadErrorMessage>,
::std::string::String,
>,
}
impl ::std::default::Default for PayloadError {
fn default() -> Self {
Self {
code: Err("no value supplied for code".to_string()),
message: Ok(Default::default()),
}
}
}
impl PayloadError {
pub fn code<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadErrorCode>,
T::Error: ::std::fmt::Display,
{
self.code = value
.try_into()
.map_err(|e| format!("error converting supplied value for code: {e}"));
self
}
pub fn message<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadErrorMessage>>,
T::Error: ::std::fmt::Display,
{
self.message = value
.try_into()
.map_err(|e| format!("error converting supplied value for message: {e}"));
self
}
}
impl ::std::convert::TryFrom<PayloadError> for super::PayloadError {
type Error = super::error::ConversionError;
fn try_from(
value: PayloadError,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
code: value.code?,
message: value.message?,
})
}
}
impl ::std::convert::From<super::PayloadError> for PayloadError {
fn from(value: super::PayloadError) -> Self {
Self {
code: Ok(value.code),
message: Ok(value.message),
}
}
}
#[derive(Clone, Debug)]
pub struct PayloadRepo {
forge_id: ::std::result::Result<super::ForgeId, ::std::string::String>,
resource: ::std::result::Result<super::RepoResource, ::std::string::String>,
}
impl ::std::default::Default for PayloadRepo {
fn default() -> Self {
Self {
forge_id: Err("no value supplied for forge_id".to_string()),
resource: Err("no value supplied for resource".to_string()),
}
}
}
impl PayloadRepo {
pub fn forge_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<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 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
}
}
impl ::std::convert::TryFrom<PayloadRepo> for super::PayloadRepo {
type Error = super::error::ConversionError;
fn try_from(
value: PayloadRepo,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
forge_id: value.forge_id?,
resource: value.resource?,
})
}
}
impl ::std::convert::From<super::PayloadRepo> for PayloadRepo {
fn from(value: super::PayloadRepo) -> Self {
Self {
forge_id: Ok(value.forge_id),
resource: Ok(value.resource),
}
}
}
#[derive(Clone, Debug)]
pub struct PayloadStepsItem {
detail: ::std::result::Result<
::std::option::Option<super::PayloadStepsItemDetail>,
::std::string::String,
>,
outcome: ::std::result::Result<super::PayloadStepsItemOutcome, ::std::string::String>,
step: ::std::result::Result<super::PayloadStepsItemStep, ::std::string::String>,
}
impl ::std::default::Default for PayloadStepsItem {
fn default() -> Self {
Self {
detail: Ok(Default::default()),
outcome: Err("no value supplied for outcome".to_string()),
step: Err("no value supplied for step".to_string()),
}
}
}
impl PayloadStepsItem {
pub fn detail<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::PayloadStepsItemDetail>>,
T::Error: ::std::fmt::Display,
{
self.detail = value
.try_into()
.map_err(|e| format!("error converting supplied value for detail: {e}"));
self
}
pub fn outcome<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadStepsItemOutcome>,
T::Error: ::std::fmt::Display,
{
self.outcome = value
.try_into()
.map_err(|e| format!("error converting supplied value for outcome: {e}"));
self
}
pub fn step<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::PayloadStepsItemStep>,
T::Error: ::std::fmt::Display,
{
self.step = value
.try_into()
.map_err(|e| format!("error converting supplied value for step: {e}"));
self
}
}
impl ::std::convert::TryFrom<PayloadStepsItem> for super::PayloadStepsItem {
type Error = super::error::ConversionError;
fn try_from(
value: PayloadStepsItem,
) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
detail: value.detail?,
outcome: value.outcome?,
step: value.step?,
})
}
}
impl ::std::convert::From<super::PayloadStepsItem> for PayloadStepsItem {
fn from(value: super::PayloadStepsItem) -> Self {
Self {
detail: Ok(value.detail),
outcome: Ok(value.outcome),
step: Ok(value.step),
}
}
}
#[derive(Clone, Debug)]
pub struct Response {
ext: ::std::result::Result<::std::option::Option<super::Ext>, ::std::string::String>,
job_id: ::std::result::Result<super::ResponseJobId, ::std::string::String>,
}
impl ::std::default::Default for Response {
fn default() -> Self {
Self {
ext: Ok(Default::default()),
job_id: Err("no value supplied for job_id".to_string()),
}
}
}
impl Response {
pub fn ext<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<::std::option::Option<super::Ext>>,
T::Error: ::std::fmt::Display,
{
self.ext = value
.try_into()
.map_err(|e| format!("error converting supplied value for ext: {e}"));
self
}
pub fn job_id<T>(mut self, value: T) -> Self
where
T: ::std::convert::TryInto<super::ResponseJobId>,
T::Error: ::std::fmt::Display,
{
self.job_id = value
.try_into()
.map_err(|e| format!("error converting supplied value for job_id: {e}"));
self
}
}
impl ::std::convert::TryFrom<Response> for super::Response {
type Error = super::error::ConversionError;
fn try_from(value: Response) -> ::std::result::Result<Self, super::error::ConversionError> {
Ok(Self {
ext: value.ext?,
job_id: value.job_id?,
})
}
}
impl ::std::convert::From<super::Response> for Response {
fn from(value: super::Response) -> Self {
Self {
ext: Ok(value.ext),
job_id: Ok(value.job_id),
}
}
}
}
impl crate::Payload for Payload {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/git-ns/bridge/result/0.1";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"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 \"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 \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"The VTC has recorded the result.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"jobId\": {\n \"maxLength\": 128,\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"jobId\"\n ],\n \"title\": \"Git Namespaces — Bridge Job Result — response payload\",\n \"type\": \"object\"\n }\n },\n \"$id\": \"https://trusttasks.org/spec/git-ns/bridge/result/0.1\",\n \"$schema\": \"https://json-schema.org/draft/2020-12/schema\",\n \"additionalProperties\": false,\n \"description\": \"The bridge reports how a job ended. Exactly one result is sent per job; the VTC updates the repository's state, bootstrap status and forge id from it.\",\n \"properties\": {\n \"error\": {\n \"additionalProperties\": false,\n \"description\": \"Why the job failed or stopped partway. Present when `outcome` is not `succeeded`.\",\n \"properties\": {\n \"code\": {\n \"description\": \"Forge-neutral: `nameTaken`, `notFound`, `forbidden` (the bridge's forge credentials lack a permission), `notCapable` (this forge or namespace cannot do it), `rateLimited`, `expired` (a begin* job's person never completed it), `forgeError`. A bridge MAY use others.\",\n \"maxLength\": 64,\n \"minLength\": 1,\n \"pattern\": \"^[a-z][A-Za-z0-9]*$\",\n \"type\": \"string\"\n },\n \"message\": {\n \"maxLength\": 1024,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"code\"\n ],\n \"type\": \"object\"\n },\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"jobId\": {\n \"description\": \"The job, as git-ns/bridge/job named it.\",\n \"maxLength\": 128,\n \"minLength\": 1,\n \"type\": \"string\"\n },\n \"outcome\": {\n \"description\": \"`succeeded` — every step was applied. `failed` — nothing was applied. `partial` — some steps were applied and at least one failed; `steps` says which. Every step is check-then-apply, so the VTC may send the job again.\",\n \"enum\": [\n \"succeeded\",\n \"failed\",\n \"partial\"\n ],\n \"type\": \"string\"\n },\n \"repo\": {\n \"additionalProperties\": false,\n \"description\": \"The repository the job touched, as the forge now reports it. Present whenever the job reached a repository.\",\n \"properties\": {\n \"forgeId\": {\n \"$ref\": \"#/$defs/ForgeId\"\n },\n \"resource\": {\n \"$ref\": \"#/$defs/RepoResource\"\n }\n },\n \"required\": [\n \"resource\",\n \"forgeId\"\n ],\n \"type\": \"object\"\n },\n \"steps\": {\n \"description\": \"Per-step outcomes, in the order they ran.\",\n \"items\": {\n \"additionalProperties\": false,\n \"properties\": {\n \"detail\": {\n \"description\": \"Human-readable detail, typically for a failure.\",\n \"maxLength\": 1024,\n \"type\": \"string\"\n },\n \"outcome\": {\n \"description\": \"`applied` — changed the forge. `unchanged` — already as required. `failed` — could not be applied. `skipped` — not attempted because an earlier step failed.\",\n \"enum\": [\n \"applied\",\n \"unchanged\",\n \"failed\",\n \"skipped\"\n ],\n \"type\": \"string\"\n },\n \"step\": {\n \"description\": \"The step name, from the adapter's plan.\",\n \"maxLength\": 64,\n \"minLength\": 1,\n \"pattern\": \"^[a-z][A-Za-z0-9]*$\",\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"step\",\n \"outcome\"\n ],\n \"type\": \"object\"\n },\n \"type\": \"array\"\n }\n },\n \"required\": [\n \"jobId\",\n \"outcome\"\n ],\n \"title\": \"Git Namespaces — Bridge Job Result — payload\",\n \"type\": \"object\"\n}\n",
);
}
impl crate::Payload for Response {
const TYPE_URI: &'static str = "https://trusttasks.org/spec/git-ns/bridge/result/0.1#response";
const IS_PROOF_REQUIRED: bool = true;
const IS_ISSUED_AT_REQUIRED: bool = true;
const IS_RECIPIENT_REQUIRED: bool = true;
const PAYLOAD_SCHEMA: Option<&'static str> = Some(
"{\n \"$defs\": {\n \"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 \"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 \"Response\": {\n \"$anchor\": \"response\",\n \"additionalProperties\": false,\n \"description\": \"The VTC has recorded the result.\",\n \"properties\": {\n \"ext\": {\n \"$ref\": \"#/$defs/Ext\"\n },\n \"jobId\": {\n \"maxLength\": 128,\n \"minLength\": 1,\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"jobId\"\n ],\n \"title\": \"Git Namespaces — Bridge Job Result — 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_JOB];
/// 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/bridge/result:unknownJob`
///
/// The VTC sent no job with this `jobId` to this bridge.
///
/// Declared `retryable: false`.
pub const UNKNOWN_JOB: crate::DeclaredErrorCode = crate::DeclaredErrorCode {
code: "git-ns/bridge/result:unknownJob",
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:fb9517a4-8ef8-41df-aef3-380e7fa51f01\",\n \"type\": \"https://trusttasks.org/spec/git-ns/bridge/result/0.1\",\n \"threadId\": \"urn:uuid:fb9517a4-8ef8-41df-aef3-380e7fa51f01\",\n \"issuer\": \"did:webvh:QmBridgeScid5:bridge.acme-vtc.example\",\n \"recipient\": \"did:webvh:QmVtcScid7:acme-vtc.example\",\n \"issuedAt\": \"2026-09-23T10:00:40Z\",\n \"payload\": {\n \"jobId\": \"job_01J8ZA3K7F\",\n \"outcome\": \"succeeded\",\n \"repo\": {\n \"resource\": \"github.com/acme/gadgets\",\n \"forgeId\": \"812736990\"\n },\n \"steps\": [\n {\n \"step\": \"create\",\n \"outcome\": \"applied\"\n },\n {\n \"step\": \"workflow\",\n \"outcome\": \"applied\"\n },\n {\n \"step\": \"keyring\",\n \"outcome\": \"applied\"\n },\n {\n \"step\": \"variables\",\n \"outcome\": \"applied\"\n },\n {\n \"step\": \"requiredCheck\",\n \"outcome\": \"applied\"\n },\n {\n \"step\": \"roles\",\n \"outcome\": \"applied\"\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-09-23T10:00:40Z\",\n \"proofPurpose\": \"authentication\",\n \"proofValue\": \"zG3UD8d6xMATBJFTFfaeRkCC5FzhYwYJpJHECtHkfV4fyjiiGesGi9vkzLE8YaZGBvTyyDQq2MMCVDzcPPLHP6F\"\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:fb9517a4-8ef8-41df-aef3-380e7fa51f03\",\n \"type\": \"https://trusttasks.org/spec/git-ns/bridge/result/0.1\",\n \"threadId\": \"urn:uuid:fb9517a4-8ef8-41df-aef3-380e7fa51f03\",\n \"issuer\": \"did:webvh:QmBridgeScid5:bridge.acme-vtc.example\",\n \"recipient\": \"did:webvh:QmVtcScid7:acme-vtc.example\",\n \"issuedAt\": \"2026-09-23T10:00:00Z\",\n \"payload\": {\n \"jobId\": \"job_01J8ZD1F5S\",\n \"outcome\": \"partial\",\n \"repo\": {\n \"resource\": \"codeberg.org/acme/sprockets\",\n \"forgeId\": \"334021\"\n },\n \"steps\": [\n {\n \"step\": \"workflow\",\n \"outcome\": \"unchanged\"\n },\n {\n \"step\": \"variables\",\n \"outcome\": \"applied\"\n },\n {\n \"step\": \"mergeStyle\",\n \"outcome\": \"applied\"\n },\n {\n \"step\": \"requiredCheck\",\n \"outcome\": \"applied\"\n },\n {\n \"step\": \"runner\",\n \"outcome\": \"failed\",\n \"detail\": \"No runner picked up the verify-trust job within 10 minutes.\"\n }\n ],\n \"error\": {\n \"code\": \"forgeError\",\n \"message\": \"The instance offers no runner for this repository; the check is required but can never pass.\"\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:00:00Z\",\n \"proofPurpose\": \"authentication\",\n \"proofValue\": \"zUo2civRis64RDNrGy84MnV3v8kbWSK3n4XD5EMrmtnTBd6hGAYWaVP6FqHENTD2Q96BP7rU51UrCFiu7MFEz1s\"\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:fb9517a4-8ef8-41df-aef3-380e7fa51f02\",\n \"type\": \"https://trusttasks.org/spec/git-ns/bridge/result/0.1#response\",\n \"threadId\": \"urn:uuid:fb9517a4-8ef8-41df-aef3-380e7fa51f01\",\n \"issuer\": \"did:webvh:QmVtcScid7:acme-vtc.example\",\n \"recipient\": \"did:webvh:QmBridgeScid5:bridge.acme-vtc.example\",\n \"issuedAt\": \"2026-09-23T10:00:41Z\",\n \"payload\": {\n \"jobId\": \"job_01J8ZA3K7F\"\n },\n \"proof\": {\n \"type\": \"DataIntegrityProof\",\n \"cryptosuite\": \"eddsa-jcs-2022\",\n \"verificationMethod\": \"did:webvh:QmVtcScid7:acme-vtc.example#key-1\",\n \"created\": \"2026-09-23T10:00:41Z\",\n \"proofPurpose\": \"authentication\",\n \"proofValue\": \"zsNBhcsMawQ96N6GJfD94KE1ySYqEVPaWB9K9q6vJ1NvvL3wPQYE3uq3CCksdFE4UNXGyr92MH1CiugbXi4EZjE\"\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)] = &[
(
"`outcome` is `succeeded`, `failed` or `partial`.",
"{\n \"jobId\": \"job_1\",\n \"outcome\": \"ok\"\n}",
),
(
"A repository in a result carries the forge's id; a name alone does not survive a rename.",
"{\n \"jobId\": \"job_1\",\n \"outcome\": \"succeeded\",\n \"repo\": {\n \"resource\": \"github.com/acme/widgets\"\n }\n}",
),
(
"Forge ids are strings, so a forge whose ids are not numbers needs no new version.",
"{\n \"jobId\": \"job_1\",\n \"outcome\": \"succeeded\",\n \"repo\": {\n \"forgeId\": 812736451,\n \"resource\": \"github.com/acme/widgets\"\n }\n}",
),
(
"A step outcome is `applied`, `unchanged`, `failed` or `skipped`.",
"{\n \"jobId\": \"job_1\",\n \"outcome\": \"partial\",\n \"steps\": [\n {\n \"outcome\": \"done\",\n \"step\": \"workflow\"\n }\n ]\n}",
),
(
"`error.code` is required when `error` is present.",
"{\n \"error\": {\n \"message\": \"boom\"\n },\n \"jobId\": \"job_1\",\n \"outcome\": \"failed\"\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
);
}
}
}