idiolect-records 0.1.0

Rust record types mirroring the dev.idiolect.* Lexicon family.
Documentation
// @generated by idiolect-codegen. do not edit.
// source: dev.idiolect.defs

//! Shared types for the dev.idiolect.* Lexicon family. Concerns that recur across record Lexicons (visibility, reference shapes, tool identity) are defined here rather than duplicated.

#![allow(
    missing_docs,
    clippy::doc_markdown,
    clippy::struct_excessive_bools,
    clippy::derive_partial_eq_without_eq
)]
use serde::{Deserialize, Serialize};

/// Reference to a prior encounter record. at-uri is canonical; cid pins the exact revision.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EncounterRef {
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub cid: Option<String>,
    pub uri: String,
}

/// Reference to a lens (translation). Either an at-uri or a content-addressed hash; at least one must be present.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LensRef {
    /// Content-addressed hash of the lens.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub cid: Option<String>,
    /// Whether the lens is invertible.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub direction: Option<LensRefDirection>,
    /// AT-URI pointing to a lens record.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub uri: Option<String>,
}

/// Reference to a schema. Either an at-uri pointing to a schema record or a content-addressed hash; at least one must be present.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SchemaRef {
    /// Content-addressed hash of the schema, when tracked in a content-addressed store such as panproto-vcs.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub cid: Option<String>,
    /// Schema language identifier, e.g. 'atproto-lexicon', 'postgres-sql', 'protobuf', 'graphql', 'json-schema'.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub language: Option<String>,
    /// AT-URI pointing to a schema record, when addressable via atproto.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub uri: Option<String>,
}

/// Identity and version of a tool used by a verifier or observer.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Tool {
    /// Optional source commit or build identifier.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub commit: Option<String>,
    /// Canonical tool name, e.g. 'panproto', 'coq', 'tlaplus', 'z3', 'nextest'.
    pub name: String,
    /// Tool version string (semver when applicable).
    pub version: String,
}

/// Visibility scope for a record. community-scoped semantics are reserved but deferred for v1; records with visibility=community-scoped must not be served to parties outside the named community once the substrate supports scope enforcement.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum Visibility {
    PublicDetailed,
    PublicMinimal,
    PublicAggregateOnly,
    CommunityScoped,
    Private,
}

/// LensRefDirection.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum LensRefDirection {
    Unidirectional,
    Bidirectional,
}