rustferry-remote 0.1.0

Versioned remote-build contracts and provider interfaces for RustFerry
Documentation
//! JSON Schema generation for Ferry Remote Build Protocol v1.

use schemars::{JsonSchema, schema_for};

use crate::{
    ArtifactDownloadRequest, ArtifactDownloadResult, ArtifactListRequest, ArtifactManifest,
    CancellationAck, CancellationRequest, CleanupConfirmation, CleanupRequest, CompileHandoff,
    CompilePhaseEvidence, EventPage, EventRequest, GitSnapshotDescriptor, HandshakeRequest,
    HandshakeResponse, IosDeviceBuildRequest, IosDeviceBuildResult, JobHandle,
    ProviderDoctorReport, ProviderDoctorRequest, RemoteBuildEvent, SealedUnsignedArchive,
    SnapshotArtifactDescriptor, SnapshotArtifactReceipt, SnapshotBuildComplete, SnapshotBuildStart,
    SnapshotJobAccepted, SnapshotSessionError, SourceBundleDescriptor,
};

/// Every standalone document exchanged or persisted by protocol v1.
///
/// The generated schema is a catalog expressed as `anyOf`; transport operations still determine
/// which concrete document is valid at each boundary.
#[derive(JsonSchema)]
#[schemars(title = "Ferry Remote Build Protocol v1", untagged)]
#[allow(clippy::large_enum_variant)]
pub enum RemoteProtocolV1Document {
    /// Client-to-provider compatibility request.
    HandshakeRequest(HandshakeRequest),
    /// Provider-to-client compatibility response.
    HandshakeResponse(HandshakeResponse),
    /// Client-to-provider readiness request.
    ProviderDoctorRequest(ProviderDoctorRequest),
    /// Provider-to-client readiness report.
    ProviderDoctorReport(ProviderDoctorReport),
    /// Declarative physical-iPhone build request.
    IosDeviceBuildRequest(IosDeviceBuildRequest),
    /// Complete public compile-to-sign handoff.
    CompileHandoff(CompileHandoff),
    /// Initial declaration for one SSH snapshot session.
    SnapshotBuildStart(SnapshotBuildStart),
    /// Separately framed deterministic source descriptor.
    SourceBundleDescriptor(SourceBundleDescriptor),
    /// Operation-bound descriptor for one GitHub dirty-source snapshot.
    GitSnapshotDescriptor(GitSnapshotDescriptor),
    /// Worker acknowledgement for one snapshot job.
    SnapshotJobAccepted(SnapshotJobAccepted),
    /// Unsigned archive descriptor and compile evidence.
    SnapshotArtifactDescriptor(SnapshotArtifactDescriptor),
    /// Client proof of durable independent artifact verification.
    SnapshotArtifactReceipt(SnapshotArtifactReceipt),
    /// Terminal non-retaining snapshot cleanup proof.
    SnapshotBuildComplete(SnapshotBuildComplete),
    /// Secret-free terminal snapshot failure.
    SnapshotSessionError(SnapshotSessionError),
    /// Public credential-free compile evidence.
    CompilePhaseEvidence(CompilePhaseEvidence),
    /// Sealed unsigned archive descriptor.
    SealedUnsignedArchive(SealedUnsignedArchive),
    /// Accepted provider job handle.
    JobHandle(JobHandle),
    /// One NDJSON event envelope.
    RemoteBuildEvent(RemoteBuildEvent),
    /// Bounded event page.
    EventPage(EventPage),
    /// Event-page request.
    EventRequest(EventRequest),
    /// Cancellation request.
    CancellationRequest(CancellationRequest),
    /// Cancellation acknowledgement.
    CancellationAck(CancellationAck),
    /// Artifact-list request.
    ArtifactListRequest(ArtifactListRequest),
    /// Artifact download request.
    ArtifactDownloadRequest(ArtifactDownloadRequest),
    /// Verified artifact download result.
    ArtifactDownloadResult(ArtifactDownloadResult),
    /// Provider cleanup request.
    CleanupRequest(CleanupRequest),
    /// Provider cleanup proof.
    CleanupConfirmation(CleanupConfirmation),
    /// Terminal build result.
    IosDeviceBuildResult(IosDeviceBuildResult),
    /// Persisted artifact provenance and integrity manifest.
    ArtifactManifest(ArtifactManifest),
}

/// Generate deterministic pretty-printed JSON Schema for protocol v1.
///
/// # Errors
///
/// Returns a serialization error if the in-memory schema cannot be encoded as JSON.
pub fn protocol_v1_schema_json() -> Result<String, serde_json::Error> {
    let mut json = serde_json::to_string_pretty(&schema_for!(RemoteProtocolV1Document))?;
    json.push('\n');
    Ok(json)
}