#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{BosStr, CowStr, DefaultStr, FromStaticStr};
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime, UriValue};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;
#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
rename_all = "camelCase",
rename = "at.podping.records.startup",
tag = "$type",
bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Startup<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub capacity: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub hive: Option<UriValue<S>>,
pub message: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub pinging_app: Option<S>,
pub server_account: S,
#[serde(skip_serializing_if = "Option::is_none")]
pub session_id: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub source: Option<S>,
pub timestamp: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub use_test_node: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub uuid: Option<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub v: Option<S>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct StartupGetRecordOutput<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub cid: Option<Cid<S>>,
pub uri: AtUri<S>,
pub value: Startup<S>,
}
impl<S: BosStr> Startup<S> {
pub fn uri(uri: S) -> Result<RecordUri<S, StartupRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new(uri)?)
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct StartupRecord;
impl XrpcResp for StartupRecord {
const NSID: &'static str = "at.podping.records.startup";
const ENCODING: &'static str = "application/json";
type Output<S: BosStr> = StartupGetRecordOutput<S>;
type Err = RecordError;
}
impl<S: BosStr> From<StartupGetRecordOutput<S>> for Startup<S> {
fn from(output: StartupGetRecordOutput<S>) -> Self {
output.value
}
}
impl<S: BosStr> Collection for Startup<S> {
const NSID: &'static str = "at.podping.records.startup";
type Record = StartupRecord;
}
impl Collection for StartupRecord {
const NSID: &'static str = "at.podping.records.startup";
type Record = StartupRecord;
}
impl<S: BosStr> LexiconSchema for Startup<S> {
fn nsid() -> &'static str {
"at.podping.records.startup"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_at_podping_records_startup()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod startup_state {
pub use crate::builder_types::{IsSet, IsUnset, Set, Unset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Timestamp;
type ServerAccount;
type Message;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Timestamp = Unset;
type ServerAccount = Unset;
type Message = Unset;
}
pub struct SetTimestamp<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetTimestamp<St> {}
impl<St: State> State for SetTimestamp<St> {
type Timestamp = Set<members::timestamp>;
type ServerAccount = St::ServerAccount;
type Message = St::Message;
}
pub struct SetServerAccount<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetServerAccount<St> {}
impl<St: State> State for SetServerAccount<St> {
type Timestamp = St::Timestamp;
type ServerAccount = Set<members::server_account>;
type Message = St::Message;
}
pub struct SetMessage<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetMessage<St> {}
impl<St: State> State for SetMessage<St> {
type Timestamp = St::Timestamp;
type ServerAccount = St::ServerAccount;
type Message = Set<members::message>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct timestamp(());
pub struct server_account(());
pub struct message(());
}
}
pub struct StartupBuilder<S: BosStr, St: startup_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<S>,
Option<UriValue<S>>,
Option<S>,
Option<S>,
Option<S>,
Option<S>,
Option<S>,
Option<Datetime>,
Option<bool>,
Option<S>,
Option<S>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> Startup<S> {
pub fn new() -> StartupBuilder<S, startup_state::Empty> {
StartupBuilder::new()
}
}
impl<S: BosStr> StartupBuilder<S, startup_state::Empty> {
pub fn new() -> Self {
StartupBuilder {
_state: PhantomData,
_fields: (
None, None, None, None, None, None, None, None, None, None, None,
),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: startup_state::State> StartupBuilder<S, St> {
pub fn capacity(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_capacity(mut self, value: Option<S>) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St: startup_state::State> StartupBuilder<S, St> {
pub fn hive(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_hive(mut self, value: Option<UriValue<S>>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> StartupBuilder<S, St>
where
St: startup_state::State,
St::Message: startup_state::IsUnset,
{
pub fn message(
mut self,
value: impl Into<S>,
) -> StartupBuilder<S, startup_state::SetMessage<St>> {
self._fields.2 = Option::Some(value.into());
StartupBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: startup_state::State> StartupBuilder<S, St> {
pub fn pinging_app(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_pinging_app(mut self, value: Option<S>) -> Self {
self._fields.3 = value;
self
}
}
impl<S: BosStr, St> StartupBuilder<S, St>
where
St: startup_state::State,
St::ServerAccount: startup_state::IsUnset,
{
pub fn server_account(
mut self,
value: impl Into<S>,
) -> StartupBuilder<S, startup_state::SetServerAccount<St>> {
self._fields.4 = Option::Some(value.into());
StartupBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: startup_state::State> StartupBuilder<S, St> {
pub fn session_id(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_session_id(mut self, value: Option<S>) -> Self {
self._fields.5 = value;
self
}
}
impl<S: BosStr, St: startup_state::State> StartupBuilder<S, St> {
pub fn source(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_source(mut self, value: Option<S>) -> Self {
self._fields.6 = value;
self
}
}
impl<S: BosStr, St> StartupBuilder<S, St>
where
St: startup_state::State,
St::Timestamp: startup_state::IsUnset,
{
pub fn timestamp(
mut self,
value: impl Into<Datetime>,
) -> StartupBuilder<S, startup_state::SetTimestamp<St>> {
self._fields.7 = Option::Some(value.into());
StartupBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: startup_state::State> StartupBuilder<S, St> {
pub fn use_test_node(mut self, value: impl Into<Option<bool>>) -> Self {
self._fields.8 = value.into();
self
}
pub fn maybe_use_test_node(mut self, value: Option<bool>) -> Self {
self._fields.8 = value;
self
}
}
impl<S: BosStr, St: startup_state::State> StartupBuilder<S, St> {
pub fn uuid(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.9 = value.into();
self
}
pub fn maybe_uuid(mut self, value: Option<S>) -> Self {
self._fields.9 = value;
self
}
}
impl<S: BosStr, St: startup_state::State> StartupBuilder<S, St> {
pub fn v(mut self, value: impl Into<Option<S>>) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_v(mut self, value: Option<S>) -> Self {
self._fields.10 = value;
self
}
}
impl<S: BosStr, St> StartupBuilder<S, St>
where
St: startup_state::State,
St::Timestamp: startup_state::IsSet,
St::ServerAccount: startup_state::IsSet,
St::Message: startup_state::IsSet,
{
pub fn build(self) -> Startup<S> {
Startup {
capacity: self._fields.0,
hive: self._fields.1,
message: self._fields.2.unwrap(),
pinging_app: self._fields.3,
server_account: self._fields.4.unwrap(),
session_id: self._fields.5,
source: self._fields.6,
timestamp: self._fields.7.unwrap(),
use_test_node: self._fields.8,
uuid: self._fields.9,
v: self._fields.10,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Startup<S> {
Startup {
capacity: self._fields.0,
hive: self._fields.1,
message: self._fields.2.unwrap(),
pinging_app: self._fields.3,
server_account: self._fields.4.unwrap(),
session_id: self._fields.5,
source: self._fields.6,
timestamp: self._fields.7.unwrap(),
use_test_node: self._fields.8,
uuid: self._fields.9,
v: self._fields.10,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_at_podping_records_startup() -> LexiconDoc<'static> {
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
LexiconDoc {
lexicon: Lexicon::Lexicon1,
id: CowStr::new_static("at.podping.records.startup"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("main"),
LexUserType::Record(LexRecord {
description: Some(
CowStr::new_static(
"Normalized podping startup fields. Record TID timestamp should represent when the event was received, useful for global ordering.",
),
),
key: Some(CowStr::new_static("tid")),
record: LexRecordRecord::Object(LexObject {
required: Some(
vec![
SmolStr::new_static("serverAccount"),
SmolStr::new_static("message"),
SmolStr::new_static("timestamp")
],
),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("capacity"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Optional, e.g. 1,078"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("hive"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Optional, e.g. https://rpc.mahdiyari.info",
),
),
format: Some(LexStringFormat::Uri),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("message"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("e.g. Podping startup complete"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("pingingApp"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Optional, e.g. hivepinger"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("serverAccount"),
LexObjectProperty::String(LexString {
description: Some(CowStr::new_static("e.g. podping.aaa")),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("sessionId"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Optional, e.g. 9887936240807410000"),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("source"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Optional source reference, minimized to save space, e.g. hive:92042659:cf11299faf19367f3f2d6bef0bf2bc4f59272506:0:podping.ccc (if mirroring the podping in hive block 92042659, transaction id cf11299faf19367f3f2d6bef0bf2bc4f59272506, first operation, hive auth podping.ccc)",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("timestamp"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Sender timestamp in ISO format, e.g. 2025-12-29T22:25:09.123Z",
),
),
format: Some(LexStringFormat::Datetime),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("useTestNode"),
LexObjectProperty::Boolean(LexBoolean {
..Default::default()
}),
);
map.insert(
SmolStr::new_static("uuid"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static(
"Optional, e.g. 38a44421-a535-42de-b634-d1f6edce18ce",
),
),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("v"),
LexObjectProperty::String(LexString {
description: Some(
CowStr::new_static("Optional, e.g. 2.1.0"),
),
..Default::default()
}),
);
map
},
..Default::default()
}),
..Default::default()
}),
);
map
},
..Default::default()
}
}