{"id":13503019,"url":"https://github.com/jonhoo/arccstr","last_synced_at":"2025-04-05T00:06:17.737Z","repository":{"id":50797904,"uuid":"83760893","full_name":"jonhoo/arccstr","owner":"jonhoo","description":"Thread-safe, reference-counted null-terminated immutable Rust strings.","archived":false,"fork":false,"pushed_at":"2024-12-31T10:26:34.000Z","size":142,"stargazers_count":43,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T12:42:35.157Z","etag":null,"topics":["reference-counting","rust-library","string"],"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/jonhoo.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-03T05:26:31.000Z","updated_at":"2025-01-19T21:37:42.000Z","dependencies_parsed_at":"2024-12-15T02:06:11.459Z","dependency_job_id":"5e0d2cf6-948e-480a-bfe8-8c32b1589046","html_url":"https://github.com/jonhoo/arccstr","commit_stats":{"total_commits":122,"total_committers":16,"mean_commits":7.625,"dds":0.139344262295082,"last_synced_commit":"36b7e5c6671e03380e55c47d9916528637b02717"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Farccstr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Farccstr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Farccstr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonhoo%2Farccstr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonhoo","download_url":"https://codeload.github.com/jonhoo/arccstr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266563,"owners_count":20910836,"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":["reference-counting","rust-library","string"],"created_at":"2024-07-31T22:02:33.670Z","updated_at":"2025-04-05T00:06:17.717Z","avatar_url":"https://github.com/jonhoo.png","language":"Rust","readme":"[![Crates.io](https://img.shields.io/crates/v/arccstr.svg)](https://crates.io/crates/arccstr)\n[![Documentation](https://docs.rs/arccstr/badge.svg)](https://docs.rs/arccstr/)\n[![codecov](https://codecov.io/gh/jonhoo/arccstr/graph/badge.svg?token=u9prymEBhI)](https://codecov.io/gh/jonhoo/arccstr)\n\nThread-safe reference-counted null-terminated strings.\n\nThis crate provides a space efficient mechanism for storing immutable strings.\nThe best illustration of this is to go over the alternatives:\n\n```rust\n// \u0026str:\n//  - content must be known at compile time or leaked for owned use (`\u0026'static str`)\n//  + can be shared between threads\n//  + space overhead is 2*usize (fat pointer to the string)\nlet s = \"foobar\";\n// String\n//  + can be created at runtime\n//  - cannot be shared between threads (except with Clone)\n//  - space overhead of 3*usize (Vec capacity and len + pointer to bytes)\n//  - accessing string requires two pointer derefs\nlet s = format!(\"foobar\");\n// CString:\n//  * mostly same as String\n//  * space overhead is 2*usize (uses Box\u003c[u8]\u003e internally)\n//  - cannot contain internal \\0 bytes\nuse std::ffi::CString;\nlet s = CString::new(\"foobar\").unwrap();\n// CStr:\n//  + space overhead is nominally just the pointer (1*usize),\n//    but in practice it also includes the length at the time of writing:\n//    https://github.com/rust-lang/rust/blob/b27f33a4d9c42ee6b5347a75a8a990a883437da9/library/core/src/ffi/c_str.rs#L104-L107\n//  - hard to construct\n//  - cannot contain internal \\0 bytes\n//  - generally cannot be shared between threds (lifetime usually not 'static)\nuse std::ffi::CStr;\nlet s: \u0026CStr = \u0026*s;\n// Arc\u003cString\u003e:\n//  + can be created at runtime\n//  + can be shared between threads\n//  - space overhead is 7*usize:\n//     - pointer to Arc\n//     - weak count\n//     - strong count\n//     - pointer to String\n//     - String overhead (3*usize)\nuse std::sync::Arc;\nlet s = ArcCStr::try_from(format!(\"foobar\")).unwrap();\n// Arc\u003cstr\u003e:\n//  + can be created at runtime\n//  + can be shared between threads\n//  - space overhead is 4*usize:\n//     - pointer to Arc\n//     - str length\n//     - weak count\n//     - strong count\nlet s: Arc\u003cstr\u003e = Arc::from(\"foobar\");\n// Arc\u003cCStr\u003e:\n//  + can be created at runtime\n//  + can be shared between threads\n//  - space overhead is 4*usize:\n//     - pointer to Arc\n//     - CStr length\n//     - weak count\n//     - strong count\n//  - cannot contain internal \\0 bytes\nlet s: Arc\u003cCStr\u003e = Arc::from(CStr::from_bytes_with_nul(b\"foobar\\0\").unwrap());\n// ArcCStr:\n//  + can be created at runtime\n//  + can be shared between threads\n//  - space overhead is 2*usize (pointer + strong count)\n//  - cannot contain internal \\0 bytes\nuse arccstr::ArcCStr;\nlet s = ArcCStr::try_from(\"foobar\").unwrap();\n```\n\nSee the [`ArcCStr`][arc] documentation for more details.\n\n[arc]: struct.ArcCStr.html\n","funding_links":[],"categories":["Rust"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonhoo%2Farccstr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonhoo%2Farccstr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonhoo%2Farccstr/lists"}