#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;
#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
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::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::{Serialize, Deserialize};
#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Startup<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub capacity: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub hive: Option<UriValue<'a>>,
#[serde(borrow)]
pub message: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub pinging_app: Option<CowStr<'a>>,
#[serde(borrow)]
pub server_account: CowStr<'a>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub session_id: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub source: Option<CowStr<'a>>,
pub timestamp: Datetime,
#[serde(skip_serializing_if = "Option::is_none")]
pub use_test_node: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub uuid: Option<CowStr<'a>>,
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub v: Option<CowStr<'a>>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct StartupGetRecordOutput<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
#[serde(borrow)]
pub cid: Option<Cid<'a>>,
#[serde(borrow)]
pub uri: AtUri<'a>,
#[serde(borrow)]
pub value: Startup<'a>,
}
impl<'a> Startup<'a> {
pub fn uri(
uri: impl Into<CowStr<'a>>,
) -> Result<RecordUri<'a, StartupRecord>, UriError> {
RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
}
}
#[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<'de> = StartupGetRecordOutput<'de>;
type Err<'de> = RecordError<'de>;
}
impl From<StartupGetRecordOutput<'_>> for Startup<'_> {
fn from(output: StartupGetRecordOutput<'_>) -> Self {
use jacquard_common::IntoStatic;
output.value.into_static()
}
}
impl Collection for Startup<'_> {
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<'a> LexiconSchema for Startup<'a> {
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::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Message;
type Timestamp;
type ServerAccount;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Message = Unset;
type Timestamp = Unset;
type ServerAccount = Unset;
}
pub struct SetMessage<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetMessage<S> {}
impl<S: State> State for SetMessage<S> {
type Message = Set<members::message>;
type Timestamp = S::Timestamp;
type ServerAccount = S::ServerAccount;
}
pub struct SetTimestamp<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetTimestamp<S> {}
impl<S: State> State for SetTimestamp<S> {
type Message = S::Message;
type Timestamp = Set<members::timestamp>;
type ServerAccount = S::ServerAccount;
}
pub struct SetServerAccount<S: State = Empty>(PhantomData<fn() -> S>);
impl<S: State> sealed::Sealed for SetServerAccount<S> {}
impl<S: State> State for SetServerAccount<S> {
type Message = S::Message;
type Timestamp = S::Timestamp;
type ServerAccount = Set<members::server_account>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct message(());
pub struct timestamp(());
pub struct server_account(());
}
}
pub struct StartupBuilder<'a, S: startup_state::State> {
_state: PhantomData<fn() -> S>,
_fields: (
Option<CowStr<'a>>,
Option<UriValue<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
Option<Datetime>,
Option<bool>,
Option<CowStr<'a>>,
Option<CowStr<'a>>,
),
_lifetime: PhantomData<&'a ()>,
}
impl<'a> Startup<'a> {
pub fn new() -> StartupBuilder<'a, startup_state::Empty> {
StartupBuilder::new()
}
}
impl<'a> StartupBuilder<'a, startup_state::Empty> {
pub fn new() -> Self {
StartupBuilder {
_state: PhantomData,
_fields: (None, None, None, None, None, None, None, None, None, None, None),
_lifetime: PhantomData,
}
}
}
impl<'a, S: startup_state::State> StartupBuilder<'a, S> {
pub fn capacity(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_capacity(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.0 = value;
self
}
}
impl<'a, S: startup_state::State> StartupBuilder<'a, S> {
pub fn hive(mut self, value: impl Into<Option<UriValue<'a>>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_hive(mut self, value: Option<UriValue<'a>>) -> Self {
self._fields.1 = value;
self
}
}
impl<'a, S> StartupBuilder<'a, S>
where
S: startup_state::State,
S::Message: startup_state::IsUnset,
{
pub fn message(
mut self,
value: impl Into<CowStr<'a>>,
) -> StartupBuilder<'a, startup_state::SetMessage<S>> {
self._fields.2 = Option::Some(value.into());
StartupBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: startup_state::State> StartupBuilder<'a, S> {
pub fn pinging_app(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.3 = value.into();
self
}
pub fn maybe_pinging_app(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.3 = value;
self
}
}
impl<'a, S> StartupBuilder<'a, S>
where
S: startup_state::State,
S::ServerAccount: startup_state::IsUnset,
{
pub fn server_account(
mut self,
value: impl Into<CowStr<'a>>,
) -> StartupBuilder<'a, startup_state::SetServerAccount<S>> {
self._fields.4 = Option::Some(value.into());
StartupBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: startup_state::State> StartupBuilder<'a, S> {
pub fn session_id(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.5 = value.into();
self
}
pub fn maybe_session_id(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.5 = value;
self
}
}
impl<'a, S: startup_state::State> StartupBuilder<'a, S> {
pub fn source(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.6 = value.into();
self
}
pub fn maybe_source(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.6 = value;
self
}
}
impl<'a, S> StartupBuilder<'a, S>
where
S: startup_state::State,
S::Timestamp: startup_state::IsUnset,
{
pub fn timestamp(
mut self,
value: impl Into<Datetime>,
) -> StartupBuilder<'a, startup_state::SetTimestamp<S>> {
self._fields.7 = Option::Some(value.into());
StartupBuilder {
_state: PhantomData,
_fields: self._fields,
_lifetime: PhantomData,
}
}
}
impl<'a, S: startup_state::State> StartupBuilder<'a, S> {
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<'a, S: startup_state::State> StartupBuilder<'a, S> {
pub fn uuid(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.9 = value.into();
self
}
pub fn maybe_uuid(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.9 = value;
self
}
}
impl<'a, S: startup_state::State> StartupBuilder<'a, S> {
pub fn v(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
self._fields.10 = value.into();
self
}
pub fn maybe_v(mut self, value: Option<CowStr<'a>>) -> Self {
self._fields.10 = value;
self
}
}
impl<'a, S> StartupBuilder<'a, S>
where
S: startup_state::State,
S::Message: startup_state::IsSet,
S::Timestamp: startup_state::IsSet,
S::ServerAccount: startup_state::IsSet,
{
pub fn build(self) -> Startup<'a> {
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<
jacquard_common::deps::smol_str::SmolStr,
jacquard_common::types::value::Data<'a>,
>,
) -> Startup<'a> {
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> {
#[allow(unused_imports)]
use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
use jacquard_lexicon::lexicon::*;
use alloc::collections::BTreeMap;
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()
}
}