Lexicon Module, codegen current lexicons

Use esquema (github:fatfingers23/esquema@9ef00b9) to generate rust code
for the lexicons that we have.

Currently, esquema doesn't seem to support top level integer types. I've
opted to temporarily remove `indexProgress` from my.spoor.log.activity
while compiling, and then adding it back afterwards.

I could compile esquema with the following added to my flake.nix
```
nativeBuildInputs = with pkgs; [
  pkg-config
  openssl
  openssl.dev
];
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
```
at a later date I will add it as a dependency, but I spent a while
trying to package esquema to no results.
This commit is contained in:
Julia Lange 2025-05-07 16:29:08 -07:00
parent 0210da9708
commit 090cb6631e
Signed by: Julia
SSH key fingerprint: SHA256:5DJcfxa5/fKCYn57dcabJa2vN2e6eT0pBerYi5SUbto
11 changed files with 245 additions and 0 deletions

3
src/lexicons/mod.rs Normal file
View file

@ -0,0 +1,3 @@
// @generated - This file is generated by esquema-codegen (forked from atrium-codegen). DO NOT EDIT.
pub mod record;
pub mod my;

3
src/lexicons/my.rs Normal file
View file

@ -0,0 +1,3 @@
// @generated - This file is generated by esquema-codegen (forked from atrium-codegen). DO NOT EDIT.
//!Definitions for the `my` namespace.
pub mod spoor;

4
src/lexicons/my/spoor.rs Normal file
View file

@ -0,0 +1,4 @@
// @generated - This file is generated by esquema-codegen (forked from atrium-codegen). DO NOT EDIT.
//!Definitions for the `my.spoor` namespace.
pub mod content;
pub mod log;

View file

@ -0,0 +1,17 @@
// @generated - This file is generated by esquema-codegen (forked from atrium-codegen). DO NOT EDIT.
//!Definitions for the `my.spoor.content` namespace.
pub mod defs;
pub mod external;
pub mod media;
#[derive(Debug)]
pub struct External;
impl atrium_api::types::Collection for External {
const NSID: &'static str = "my.spoor.content.external";
type Record = external::Record;
}
#[derive(Debug)]
pub struct Media;
impl atrium_api::types::Collection for Media {
const NSID: &'static str = "my.spoor.content.media";
type Record = media::Record;
}

View file

@ -0,0 +1,19 @@
// @generated - This file is generated by esquema-codegen (forked from atrium-codegen). DO NOT EDIT.
//!Definitions for the `my.spoor.content.defs` namespace.
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct TitleData {
#[serde(skip_serializing_if = "core::option::Option::is_none")]
pub lang: core::option::Option<atrium_api::types::string::Language>,
#[serde(skip_serializing_if = "core::option::Option::is_none")]
pub translation_type: core::option::Option<atrium_api::types::string::Nsid>,
#[serde(skip_serializing_if = "core::option::Option::is_none")]
pub value: core::option::Option<String>,
}
pub type Title = atrium_api::types::Object<TitleData>;
///A phonetic transcription of the native title such that when read it will sound like the native title.
pub const TITLE_HOMOPHONIC: &str = "my.spoor.content.defs#titleHomophonic";
///The title in its native script
pub const TITLE_NATIVE: &str = "my.spoor.content.defs#titleNative";
///A translation of the title
pub const TITLE_TRANSLATION: &str = "my.spoor.content.defs#titleTranslation";

View file

@ -0,0 +1,28 @@
// @generated - This file is generated by esquema-codegen (forked from atrium-codegen). DO NOT EDIT.
//!Definitions for the `my.spoor.content.external` namespace.
use atrium_api::types::TryFromUnknown;
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct RecordData {
///User defined overrides for the returned content
#[serde(skip_serializing_if = "core::option::Option::is_none")]
pub overrides: core::option::Option<atrium_api::types::Union<RecordOverridesRefs>>,
///All the data needed to query the content from the source
pub queryable: atrium_api::types::Union<RecordQueryableRefs>,
///An nsid for a specific data source. The domain authority governs how to process the queryable
pub source: atrium_api::types::string::Nsid,
#[serde(skip_serializing_if = "core::option::Option::is_none")]
pub titles: core::option::Option<Vec<crate::my::spoor::content::defs::Title>>,
}
pub type Record = atrium_api::types::Object<RecordData>;
impl From<atrium_api::types::Unknown> for RecordData {
fn from(value: atrium_api::types::Unknown) -> Self {
Self::try_from_unknown(value).unwrap()
}
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(tag = "$type")]
pub enum RecordOverridesRefs {}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(tag = "$type")]
pub enum RecordQueryableRefs {}

View file

@ -0,0 +1,44 @@
// @generated - This file is generated by esquema-codegen (forked from atrium-codegen). DO NOT EDIT.
//!Definitions for the `my.spoor.content.media` namespace.
use atrium_api::types::TryFromUnknown;
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct RecordData {
#[serde(skip_serializing_if = "core::option::Option::is_none")]
pub duration_data: core::option::Option<
atrium_api::types::Union<RecordDurationDataRefs>,
>,
///Client-declared timestamp for when this activity was last updated
pub last_updated: atrium_api::types::string::Datetime,
#[serde(skip_serializing_if = "core::option::Option::is_none")]
pub poster_image: core::option::Option<atrium_api::types::BlobRef>,
pub titles: Vec<crate::my::spoor::content::defs::Title>,
}
pub type Record = atrium_api::types::Object<RecordData>;
impl From<atrium_api::types::Unknown> for RecordData {
fn from(value: atrium_api::types::Unknown) -> Self {
Self::try_from_unknown(value).unwrap()
}
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct BookData {
#[serde(skip_serializing_if = "core::option::Option::is_none")]
pub chapters: core::option::Option<usize>,
}
pub type Book = atrium_api::types::Object<BookData>;
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct TelevisionData {
#[serde(skip_serializing_if = "core::option::Option::is_none")]
pub episodes: core::option::Option<usize>,
}
pub type Television = atrium_api::types::Object<TelevisionData>;
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(tag = "$type")]
pub enum RecordDurationDataRefs {
#[serde(rename = "my.spoor.content.media#television")]
MySpoorContentMediaTelevision(Box<crate::my::spoor::content::media::Television>),
#[serde(rename = "my.spoor.content.media#book")]
MySpoorContentMediaBook(Box<crate::my::spoor::content::media::Book>),
}

View file

@ -0,0 +1,16 @@
// @generated - This file is generated by esquema-codegen (forked from atrium-codegen). DO NOT EDIT.
//!Definitions for the `my.spoor.log` namespace.
pub mod activity;
pub mod session;
#[derive(Debug)]
pub struct Activity;
impl atrium_api::types::Collection for Activity {
const NSID: &'static str = "my.spoor.log.activity";
type Record = activity::Record;
}
#[derive(Debug)]
pub struct Session;
impl atrium_api::types::Collection for Session {
const NSID: &'static str = "my.spoor.log.session";
type Record = session::Record;
}

View file

@ -0,0 +1,26 @@
// @generated - This file is generated by esquema-codegen (forked from atrium-codegen). DO NOT EDIT.
//!Definitions for the `my.spoor.log.activity` namespace.
use atrium_api::types::TryFromUnknown;
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct RecordData {
///Client-declared timestamp for when this activity was created
pub created_at: atrium_api::types::string::Datetime,
///User-declared timestamp for when they performed the activity. Null implies unknown time.
#[serde(skip_serializing_if = "core::option::Option::is_none")]
pub performed_at: core::option::Option<atrium_api::types::string::Datetime>,
pub progress: atrium_api::types::Union<RecordProgressRefs>,
pub session: crate::com::atproto::repo::strong_ref::Main,
}
pub type Record = atrium_api::types::Object<RecordData>;
impl From<atrium_api::types::Unknown> for RecordData {
fn from(value: atrium_api::types::Unknown) -> Self {
Self::try_from_unknown(value).unwrap()
}
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(tag = "$type")]
pub enum RecordProgressRefs {
#[serde(rename = "my.spoor.log.activity#indexProgress")]
MySpoorLogActivityIndexProgress(Box<crate::my::spoor::log::activity::IndexProgress>),
}

View file

@ -0,0 +1,20 @@
// @generated - This file is generated by esquema-codegen (forked from atrium-codegen). DO NOT EDIT.
//!Definitions for the `my.spoor.log.session` namespace.
use atrium_api::types::TryFromUnknown;
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct RecordData {
pub content: crate::com::atproto::repo::strong_ref::Main,
///Client-declared timestamp for when this activity was created
pub created_at: atrium_api::types::string::Datetime,
#[serde(skip_serializing_if = "core::option::Option::is_none")]
pub label: core::option::Option<String>,
#[serde(skip_serializing_if = "core::option::Option::is_none")]
pub other_participants: core::option::Option<Vec<atrium_api::types::string::Did>>,
}
pub type Record = atrium_api::types::Object<RecordData>;
impl From<atrium_api::types::Unknown> for RecordData {
fn from(value: atrium_api::types::Unknown) -> Self {
Self::try_from_unknown(value).unwrap()
}
}

65
src/lexicons/record.rs Normal file
View file

@ -0,0 +1,65 @@
// @generated - This file is generated by esquema-codegen (forked from atrium-codegen). DO NOT EDIT.
//!A collection of known record types.
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(tag = "$type")]
pub enum KnownRecord {
#[serde(rename = "my.spoor.content.external")]
LexiconsMySpoorContentExternal(
Box<crate::lexicons::my::spoor::content::external::Record>,
),
#[serde(rename = "my.spoor.content.media")]
LexiconsMySpoorContentMedia(Box<crate::lexicons::my::spoor::content::media::Record>),
#[serde(rename = "my.spoor.log.activity")]
LexiconsMySpoorLogActivity(Box<crate::lexicons::my::spoor::log::activity::Record>),
#[serde(rename = "my.spoor.log.session")]
LexiconsMySpoorLogSession(Box<crate::lexicons::my::spoor::log::session::Record>),
}
impl From<crate::lexicons::my::spoor::content::external::Record> for KnownRecord {
fn from(record: crate::lexicons::my::spoor::content::external::Record) -> Self {
KnownRecord::LexiconsMySpoorContentExternal(Box::new(record))
}
}
impl From<crate::lexicons::my::spoor::content::external::RecordData> for KnownRecord {
fn from(
record_data: crate::lexicons::my::spoor::content::external::RecordData,
) -> Self {
KnownRecord::LexiconsMySpoorContentExternal(Box::new(record_data.into()))
}
}
impl From<crate::lexicons::my::spoor::content::media::Record> for KnownRecord {
fn from(record: crate::lexicons::my::spoor::content::media::Record) -> Self {
KnownRecord::LexiconsMySpoorContentMedia(Box::new(record))
}
}
impl From<crate::lexicons::my::spoor::content::media::RecordData> for KnownRecord {
fn from(
record_data: crate::lexicons::my::spoor::content::media::RecordData,
) -> Self {
KnownRecord::LexiconsMySpoorContentMedia(Box::new(record_data.into()))
}
}
impl From<crate::lexicons::my::spoor::log::activity::Record> for KnownRecord {
fn from(record: crate::lexicons::my::spoor::log::activity::Record) -> Self {
KnownRecord::LexiconsMySpoorLogActivity(Box::new(record))
}
}
impl From<crate::lexicons::my::spoor::log::activity::RecordData> for KnownRecord {
fn from(record_data: crate::lexicons::my::spoor::log::activity::RecordData) -> Self {
KnownRecord::LexiconsMySpoorLogActivity(Box::new(record_data.into()))
}
}
impl From<crate::lexicons::my::spoor::log::session::Record> for KnownRecord {
fn from(record: crate::lexicons::my::spoor::log::session::Record) -> Self {
KnownRecord::LexiconsMySpoorLogSession(Box::new(record))
}
}
impl From<crate::lexicons::my::spoor::log::session::RecordData> for KnownRecord {
fn from(record_data: crate::lexicons::my::spoor::log::session::RecordData) -> Self {
KnownRecord::LexiconsMySpoorLogSession(Box::new(record_data.into()))
}
}
impl Into<atrium_api::types::Unknown> for KnownRecord {
fn into(self) -> atrium_api::types::Unknown {
atrium_api::types::TryIntoUnknown::try_into_unknown(&self).unwrap()
}
}