{"id":17038403,"url":"https://github.com/matklad/typed_key","last_synced_at":"2025-04-12T13:52:28.871Z","repository":{"id":57670883,"uuid":"134696385","full_name":"matklad/typed_key","owner":"matklad","description":"A Rust library for strongly-typed string keys for configuration.","archived":false,"fork":false,"pushed_at":"2018-06-03T06:33:55.000Z","size":34,"stargazers_count":25,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T05:38:02.461Z","etag":null,"topics":["rust","type-safety"],"latest_commit_sha":null,"homepage":"https://matklad.github.io/2018/05/24/typed-key-pattern.html","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/matklad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-24T09:59:03.000Z","updated_at":"2023-05-27T08:38:36.000Z","dependencies_parsed_at":"2022-09-26T20:41:22.604Z","dependency_job_id":null,"html_url":"https://github.com/matklad/typed_key","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matklad%2Ftyped_key","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matklad%2Ftyped_key/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matklad%2Ftyped_key/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matklad%2Ftyped_key/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matklad","download_url":"https://codeload.github.com/matklad/typed_key/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248576194,"owners_count":21127340,"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":["rust","type-safety"],"created_at":"2024-10-14T08:56:45.988Z","updated_at":"2025-04-12T13:52:28.849Z","avatar_url":"https://github.com/matklad.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# typed_key\n\n[![Build Status](https://travis-ci.org/matklad/typed_key.svg?branch=master)](https://travis-ci.org/matklad/typed_key)\n[![Crates.io](https://img.shields.io/crates/v/typed_key.svg)](https://crates.io/crates/typed_key)\n[![API reference](https://docs.rs/typed_key/badge.svg)](https://docs.rs/typed_key/)\n\n\nStrongly-typed string keys for configuration.\n\nA frequent task is to extract a typed value from an untyped `Map\u003cString, Object\u003e`.\nTypically, this is done via string keys: `let port: u32 = map.get(\"port\")?.parse()?`.\nA slightly more type-safe approach is to associate certain types with corresponding\nstring constants:\n\n```rust\n#[macro_use]\nextern crate typed_key;\nuse typed_key::Key;\n\n// `PORT` is basically `\"port\"` string with associated `u32` type.\nconst PORT: Key\u003cu32\u003e = typed_key!(\"port\");\n```\n\nThis crate provides basic building block for such strongly-typed strings.\nSee [example] for a complete example of reading configuration, and the [blog post]\nfor a more long winded explanation of the pattern.\n\n[example]: https://github.com/matklad/typed_key/blob/master/examples/serde.rs\n[blog post]: https://matklad.github.io/2018/05/24/typed-key-pattern.html\n\nUsing string keys is totally fine for small isolated cases, but if this pattern\nis pervasive, `typed_key` can provide the following benefits:\n\n  * Documentation: all possible keys are declared in one place, specify\n    their type explicitly, and can have documentation comments.\n  * Type safety: because each key carries its type, it's impossible to read\n    the value of wrong type. Unlike string keys, typed keys never need a turbofish\n    operator.\n  * Typo safety: you can't misspell a type key on the call site.\n  * Navigation: with typed_keys, you can use \"go to definition\", \"find usages\", and\n    refactor without fear.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatklad%2Ftyped_key","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatklad%2Ftyped_key","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatklad%2Ftyped_key/lists"}