{"id":22297487,"url":"https://github.com/rustonaut/rust-dynobject","last_synced_at":"2025-07-12T01:03:01.575Z","repository":{"id":28270087,"uuid":"31780459","full_name":"rustonaut/rust-dynobject","owner":"rustonaut","description":"Kind of dynamic Objects for rust. Allowing to create, change and access typed properties with runtime type checks","archived":false,"fork":false,"pushed_at":"2015-03-11T13:11:46.000Z","size":228,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T22:43:46.113Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rustonaut.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-06T17:24:20.000Z","updated_at":"2020-06-01T06:44:51.000Z","dependencies_parsed_at":"2022-08-27T18:32:44.352Z","dependency_job_id":null,"html_url":"https://github.com/rustonaut/rust-dynobject","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rustonaut/rust-dynobject","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustonaut%2Frust-dynobject","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustonaut%2Frust-dynobject/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustonaut%2Frust-dynobject/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustonaut%2Frust-dynobject/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rustonaut","download_url":"https://codeload.github.com/rustonaut/rust-dynobject/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustonaut%2Frust-dynobject/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264922786,"owners_count":23683690,"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-03T17:49:56.438Z","updated_at":"2025-07-12T01:03:01.484Z","avatar_url":"https://github.com/rustonaut.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dynobject\n[![Build Status](https://travis-ci.org/naicode/rust-dynobject.svg?branch=master)](https://travis-ci.org/naicode/rust-dynobject)\n\nKind of dynamic Objects for rust. Allowing to create, change and access typed properties with runtime type checks\n\n**Note:** Rust has perfectly fine mechanismen to do mostly everything without refering to such a roundabout _crates_ like _dynobject_\n\nThe DynObject is a dynamic Object witch has interiour mutablility and reference counting allowing it easly to be shared betwenn\nownership boundaries (but not threads!). When acccessing properties it is ensured that no objects are destructed per default when\na operation fails (`expect DynProperty::destruct`). This nevertheless means that you will have to handle many results. But there\nare some nice result levering macros like `try!` to keep you code cleaner.\n\nThe dokumentation is done over the rustdoc tool, seadly I havent integrated it yet into github so you need to run rustdoc yourself\nor look into the source files.\n\n# Examples\n\n```rust\nextern crate dynobject;\n\nuse dynobject::DynObject;\n\n//for simplicity use \u0026'static str\ntype Key = \u0026'static str;\n\n//with intorior mutablility\n//if you do not want this just change\n//`fn run(\u0026self)...` to `fn run(\u0026mut self)...`\nstruct Processor {\n\tshared_data: DynObject\u003cKey\u003e,\n\t//there are will soon be unboxed closures witch could be used here insted of Box\u003cFn...\u003e\n\trunner: Box\u003cFn(\u0026DynObject\u003cKey\u003e) -\u003e bool\u003e\n}\n\nimpl Processor {\n\tfn run(\u0026self) -\u003e bool {\n\t\t(self.runner)(\u0026self.shared_data)\n\t}\n}\n\nfn run_to_end(pr: \u0026Processor) {\n\twhile pr.run() { \n\t\tprintln!(\"running\");\n\t}\n}\n\nfn setup_data(outer_obj: \u0026DynObject\u003cKey\u003e) {\n\t#![allow(unused_must_use)]\n\tlet mut obj = outer_obj.aquire();\n\tobj.create_property(\"counter1\", Box::new(0u32));\n\tobj.create_property(\"counter2\", Box::new(1u32));\n\tobj.create_property(\"limit\", Box::new(4u32));\n}\n\nfn main() {\n\tlet obj = DynObject::\u003cKey\u003e::new();\n\tsetup_data( \u0026obj );\n\tlet p1 = Processor {\n\t\tshared_data: obj.clone(),\n\t\trunner: Box::new( |data: \u0026DynObject\u003cKey\u003e| -\u003e bool {\n\t\t\tlet mut obj = data.aquire();\n\t\t\tlet value = *obj[\"counter1\"].as_ref::\u003cu32\u003e().unwrap() + 1;\n\t\t\t*obj[\"counter1\"].as_mut::\u003cu32\u003e().unwrap() = value;\n\t\t\tprintln!(\"reached {}\", value);\n\t\t\tobj[\"limit\"].as_ref::\u003cu32\u003e().unwrap() \u003e= \u0026value\n\t\t} )\n\t};\n\tlet p2 = Processor {\n\t\tshared_data: obj.clone(),\n\t\trunner: Box::new( |data: \u0026DynObject\u003cKey\u003e| -\u003e bool {\n\t\t\tlet mut obj = data.aquire();\n\t\t\t*obj[\"counter2\"].as_mut::\u003cu32\u003e().unwrap() += 2;\n            let ref_2_counter1 = obj[\"counter1\"].as_mut::\u003cu32\u003e().unwrap();\n            *ref_2_counter1 -= 1;\n            *ref_2_counter1 \u003e 0 \n\t\t} )\n\t};\n\t\n\trun_to_end( \u0026p1 );\n\trun_to_end( \u0026p2 );\n\n    let accessor = obj.aquire();\n    let c1 = accessor[\"counter1\"].as_ref::\u003cu32\u003e().unwrap();\n    let c2 = accessor[\"counter2\"].as_ref::\u003cu32\u003e().unwrap();\n    let limit = accessor[\"limit\"].as_ref::\u003cu32\u003e().unwrap();\n\tprintln!( \"c1: {}, c2: {}, limit: {}\", c1, c2, limit );\n}\t\n```\n\n# Calling Guards\nThere is a calling guard branch witch extends the Object by Funktion/Closure based Guards witch are called on create, remove, access(mut),\naccess(ref) operatons and let the fail. This is usefull for logging purpose and some other stuff. Neverless due too the limitations\nof the current design thes will not be merged with the main branch (even throug a programm compatible with the mainbranch should be\ncompatible with the calling-guard branch too, due too the same method signatures).\n\n# License\nApache v2\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustonaut%2Frust-dynobject","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frustonaut%2Frust-dynobject","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustonaut%2Frust-dynobject/lists"}