{"id":23115409,"url":"https://github.com/jcaesar/structstruck","last_synced_at":"2025-04-04T19:10:57.387Z","repository":{"id":57663630,"uuid":"479951505","full_name":"jcaesar/structstruck","owner":"jcaesar","description":"Rust nested structs","archived":false,"fork":false,"pushed_at":"2025-03-23T14:43:08.000Z","size":71,"stargazers_count":55,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T18:14:14.284Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jcaesar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-10T08:02:17.000Z","updated_at":"2025-03-23T14:43:11.000Z","dependencies_parsed_at":"2024-12-15T13:22:02.643Z","dependency_job_id":"7e0662ac-8467-4b02-bd64-92beb81d98b4","html_url":"https://github.com/jcaesar/structstruck","commit_stats":{"total_commits":47,"total_committers":4,"mean_commits":11.75,"dds":0.5106382978723405,"last_synced_commit":"1f0c3b64a3fac90e0bab66fbb7fb7b77a739c9af"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcaesar%2Fstructstruck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcaesar%2Fstructstruck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcaesar%2Fstructstruck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcaesar%2Fstructstruck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcaesar","download_url":"https://codeload.github.com/jcaesar/structstruck/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247234921,"owners_count":20905854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-17T03:41:17.391Z","updated_at":"2025-04-04T19:10:57.368Z","avatar_url":"https://github.com/jcaesar.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StructStruck\n\nEver had a deeply nested JSON struct\n```json\n{\n    \"outer\": {\n        \"middle\": {\n            \"inner\": {\n                \"foo\": \"bar\"\n            }\n        }\n    }\n}\n```\nand wanted to write the Rust structs to handle that data just in the same nested way?\n```rust\nstruct Parent {\n    outer: struct {\n        middle: struct {\n            inner: struct {\n                foo: String,\n            }\n        }\n    }\n}\n```\nThis proc macro crate allows exactly that.\nCheck the [docs](https://docs.rs/structstruck) on how exaclty.\n\nFor illustration, some more usecases:\n\n* an enum where every variant has its own struct, named exactly the same as the variant.\n```rust\nstructstruck::strike! {\n    enum Token {\n        Identifier(struct {\n            name: String,\n        }),\n        Punctuation(struct {\n            character: char,\n        }),\n    }\n}\n```\n\n* my original use case: conveniently write kubernetes custom resources with `kube`.\n```rust\nstructstruck::strike! {\n    #[strctstruck::each[derive(Deserialize, Serialize, Clone, Debug, Validate, JsonSchema)]]\n    #[strctstruck::each[serde(rename_all = \"camelCase\")]]\n    #[derive(CustomResource)]\n    #[kube(\n        group = \"kafka.strimzi.io\",\n        version = \"v1beta2\",\n        kind = \"Kafka\",\n        namespaced\n    )]\n    struct KafkaSpec {\n        kafka: struct KafkaCluster {\n            #[validate(length(min = 1))]\n            version: String,\n            #[validate(range(min = 1))]\n            replicas: u32,\n            listeners: Vec\u003cstruct KafkaListener {\n                name: String,\n                port: u16,\n                r#type: String,\n                tls: bool,\n            }\u003e,\n            config: HashMap\u003cString, JsonValue\u003e,\n            storage: struct {\n                r#type: String,\n                volumes: Vec\u003cstruct Volume {\n                    id: Option\u003cu64\u003e,\n                    r#type: String,\n                    size: String,\n                    delete_claim: bool,\n                }\u003e,\n            },\n        },\n        zookeeper: struct {\n            #[validate(range(min = 1))]\n            replicas: u32,\n            storage: Volume,\n        },\n        entity_operator: struct {\n            topic_operator: Option\u003cHashMap\u003cString, JsonValue\u003e\u003e,\n            user_operator: Option\u003cHashMap\u003cString, JsonValue\u003e\u003e,\n        },\n    }\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcaesar%2Fstructstruck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcaesar%2Fstructstruck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcaesar%2Fstructstruck/lists"}