jacquard-api 0.11.0

Generated AT Protocol API bindings for Jacquard
Documentation
// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: blog.pckt.content
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::blob::BlobRef;
use jacquard_common::types::value::Data;
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};
/// Hybrid content storage: inline for small content (≤20KB), blob for large content (>20KB)

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Content<'a> {
    ///Reference to external JSON blob containing content (extended mode, used when content > 20KB)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub blob: Option<BlobRef<'a>>,
    ///Array of content blocks (inline mode, used when content ≤ 20KB)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub items: Option<Vec<Data<'a>>>,
    ///Array of blob references (full objects) used in the content (required in extended mode to prevent garbage collection)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub references: Option<Vec<BlobRef<'a>>>,
}

impl<'a> LexiconSchema for Content<'a> {
    fn nsid() -> &'static str {
        "blog.pckt.content"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_blog_pckt_content()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

fn lexicon_doc_blog_pckt_content() -> 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("blog.pckt.content"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Hybrid content storage: inline for small content (≤20KB), blob for large content (>20KB)",
                        ),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("blob"),
                            LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("items"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Array of content blocks (inline mode, used when content ≤ 20KB)",
                                    ),
                                ),
                                items: LexArrayItem::Union(LexRefUnion {
                                    refs: vec![],
                                    closed: Some(false),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("references"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Array of blob references (full objects) used in the content (required in extended mode to prevent garbage collection)",
                                    ),
                                ),
                                items: LexArrayItem::Blob(LexBlob { ..Default::default() }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}