{"id":17791219,"url":"https://github.com/schell/broomdog","last_synced_at":"2026-03-05T16:13:05.815Z","repository":{"id":144718953,"uuid":"614099335","full_name":"schell/broomdog","owner":"schell","description":"🧹🐕 Rust library providing a map of type-erased values with indefinite loanership semantics","archived":false,"fork":false,"pushed_at":"2024-09-15T18:17:52.000Z","size":18,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-06T02:15:34.373Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/schell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2023-03-14T22:21:18.000Z","updated_at":"2025-06-26T11:32:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"f00f14a0-34a8-4875-91e6-f57944aa8e49","html_url":"https://github.com/schell/broomdog","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/schell/broomdog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schell%2Fbroomdog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schell%2Fbroomdog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schell%2Fbroomdog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schell%2Fbroomdog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schell","download_url":"https://codeload.github.com/schell/broomdog/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schell%2Fbroomdog/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269447942,"owners_count":24418762,"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","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-10-27T10:50:18.204Z","updated_at":"2026-03-05T16:13:05.742Z","avatar_url":"https://github.com/schell.png","language":"Rust","readme":"# broomdog 🧹🐕\n\n`broomdog` is a Rust library providing a map of type-erased values with indefinite loanership semantics.\n\n## what is a type map?\n\n`broomdog`'s type map is a map of `std::any::TypeId` keys to type-erased values.\nThere may be at most one value for each key, which means the map stores singleton values of different types.\n\n## why another type map library?\n\n`broomdog` provides the usual map-like API, and then some.\nNotably `broomdog` provides \"indefinite loanership\".\n\n### wtf is indefinite loanership?\n\nIt's a wordsmush that roughly means you can borrow a value from the map without\na lifetime.\n\n#### wtf is a loaned value?\n\nA loaned value is a smart pointer to a value that you can `deref` or `deref_mut`.\n\nYou may only have one exclusive (write) loan of any one type at a time, but you may have as many non-exclusive (read) loans of the same type as you like. You may also have **multiple exclusive loans of _different_ types at the same time**.\n\nAfter an exclusive loan is dropped you may make another exclusive loan of the same type, or multiple non-exclusive loans of that type.\n\nThis allows you to make multiple loans of different types at the same time, without map borrow conflicts - so long as you don't try to share an exclusive loan of the same type at the same time.\n\nFurthermore, `broomdog` has nice descriptive errors with the names of the types (more even, if compiled with `debug_assertions`).\n\n## uses\n\nType erased maps have many uses, but `broomdog` was built to facilitate the following:\n\n* singleton resource storage layer for [`apecs`](https://github.com/schell/apecs)'s system schedule runner (`apecs` is an ECS library)\n* singleton resource storage layer for [`renderling`](https://github.com/schell/renderling)'s render node schedule runner (part of the render graph)\n\nIt works particularly well with [`dagga`](https://github.com/schell/dagga), which is a DAG scheduler. In fact, `dagga` and `broomdog` are joined in [`moongraph`](https://github.com/schell/moongraph) with some nice helpers to form a DAG scheduling, resource management and execution library.\n\nTogether it's possible to define and run an extensible system of functions that share mutable resources, some of which may run in parallel.\n\n\n## why (the heck) did you name it `broomdog`\n\n* \"broomdog\" is the name of the part broom / part dog character in Alice in Wonderland that erases the path as it walks along it.\n\n* I think names should be funny.\n\n* It's my library, oh well 😏.\n\n# example\n\n```rust\nuse broomdog::{TypeMap, TypeKey};\n\nlet mut map = TypeMap::default();\nassert!(map.insert_value(0usize).unwrap().is_none());\nassert!(map.insert_value(0.0f32).unwrap().is_none());\nassert!(map.insert_value(\"hello\").unwrap().is_none());\n\n{\n    let num_usize = map.get_value_mut::\u003cusize\u003e().unwrap().unwrap();\n    *num_usize += 666;\n}\nassert_eq!(666, *map.get_value::\u003cusize\u003e().unwrap().unwrap());\nassert_eq!(\"hello\", *map.get_value::\u003c\u0026str\u003e().unwrap().unwrap());\n\n{\n    let loan = map.loan(TypeKey::new::\u003cusize\u003e()).unwrap().unwrap();\n    assert_eq!(666, *loan.downcast_ref::\u003cusize\u003e().unwrap());\n    let loan2 = map.loan(TypeKey::new::\u003cusize\u003e()).unwrap().unwrap();\n    assert_eq!(666, *loan2.downcast_ref::\u003cusize\u003e().unwrap());\n\n    let mut loan_mut = map.loan_mut(TypeKey::new::\u003c\u0026str\u003e()).unwrap().unwrap();\n    let word = loan_mut.downcast_mut::\u003c\u0026str\u003e().unwrap();\n    assert_eq!(\"hello\", *word);\n    *word = \"goodbye\";\n}\n\nmap.unify().unwrap();\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschell%2Fbroomdog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschell%2Fbroomdog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschell%2Fbroomdog/lists"}