A better Rust ATProto crate
109
fork

Configure Feed

Select the types of activity you want to include in your feed.

types modules, base string type yoinked from merde

Orual 7f513e14 4ae6df30

+900 -23
+15
.zed/settings.json
··· 1 + // Folder-specific settings 2 + // 3 + // For a full list of overridable settings, and general information on folder-specific settings, 4 + // see the documentation: https://zed.dev/docs/configuring-zed#settings-files 5 + { 6 + "lsp": { 7 + "rust-analyzer": { 8 + "initialization_options": { 9 + "rust": { 10 + "analyzerTargetDir": true 11 + } 12 + } 13 + } 14 + } 15 + }
+219
Cargo.lock
··· 3 3 version = 4 4 4 5 5 [[package]] 6 + name = "aho-corasick" 7 + version = "1.1.3" 8 + source = "registry+https://github.com/rust-lang/crates.io-index" 9 + checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" 10 + dependencies = [ 11 + "memchr", 12 + ] 13 + 14 + [[package]] 6 15 name = "anstream" 7 16 version = "0.6.20" 8 17 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 53 62 ] 54 63 55 64 [[package]] 65 + name = "base-x" 66 + version = "0.2.11" 67 + source = "registry+https://github.com/rust-lang/crates.io-index" 68 + checksum = "4cbbc9d0964165b47557570cce6c952866c2678457aca742aafc9fb771d30270" 69 + 70 + [[package]] 71 + name = "castaway" 72 + version = "0.2.4" 73 + source = "registry+https://github.com/rust-lang/crates.io-index" 74 + checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a" 75 + dependencies = [ 76 + "rustversion", 77 + ] 78 + 79 + [[package]] 80 + name = "cfg-if" 81 + version = "1.0.3" 82 + source = "registry+https://github.com/rust-lang/crates.io-index" 83 + checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" 84 + 85 + [[package]] 86 + name = "cid" 87 + version = "0.11.1" 88 + source = "registry+https://github.com/rust-lang/crates.io-index" 89 + checksum = "3147d8272e8fa0ccd29ce51194dd98f79ddfb8191ba9e3409884e751798acf3a" 90 + dependencies = [ 91 + "core2", 92 + "multibase", 93 + "multihash", 94 + "unsigned-varint", 95 + ] 96 + 97 + [[package]] 56 98 name = "clap" 57 99 version = "4.5.48" 58 100 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 99 141 checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" 100 142 101 143 [[package]] 144 + name = "compact_str" 145 + version = "0.9.0" 146 + source = "registry+https://github.com/rust-lang/crates.io-index" 147 + checksum = "3fdb1325a1cece981e8a296ab8f0f9b63ae357bd0784a9faaf548cc7b480707a" 148 + dependencies = [ 149 + "castaway", 150 + "cfg-if", 151 + "itoa", 152 + "rustversion", 153 + "ryu", 154 + "static_assertions", 155 + ] 156 + 157 + [[package]] 158 + name = "core2" 159 + version = "0.4.0" 160 + source = "registry+https://github.com/rust-lang/crates.io-index" 161 + checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505" 162 + dependencies = [ 163 + "memchr", 164 + ] 165 + 166 + [[package]] 167 + name = "data-encoding" 168 + version = "2.9.0" 169 + source = "registry+https://github.com/rust-lang/crates.io-index" 170 + checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476" 171 + 172 + [[package]] 173 + name = "data-encoding-macro" 174 + version = "0.1.18" 175 + source = "registry+https://github.com/rust-lang/crates.io-index" 176 + checksum = "47ce6c96ea0102f01122a185683611bd5ac8d99e62bc59dd12e6bda344ee673d" 177 + dependencies = [ 178 + "data-encoding", 179 + "data-encoding-macro-internal", 180 + ] 181 + 182 + [[package]] 183 + name = "data-encoding-macro-internal" 184 + version = "0.1.16" 185 + source = "registry+https://github.com/rust-lang/crates.io-index" 186 + checksum = "8d162beedaa69905488a8da94f5ac3edb4dd4788b732fadb7bd120b2625c1976" 187 + dependencies = [ 188 + "data-encoding", 189 + "syn", 190 + ] 191 + 192 + [[package]] 102 193 name = "heck" 103 194 version = "0.5.0" 104 195 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 109 200 version = "1.70.1" 110 201 source = "registry+https://github.com/rust-lang/crates.io-index" 111 202 checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" 203 + 204 + [[package]] 205 + name = "itoa" 206 + version = "1.0.15" 207 + source = "registry+https://github.com/rust-lang/crates.io-index" 208 + checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" 112 209 113 210 [[package]] 114 211 name = "jacquard" ··· 118 215 ] 119 216 120 217 [[package]] 218 + name = "jacquard-common" 219 + version = "0.1.0" 220 + dependencies = [ 221 + "cid", 222 + "compact_str", 223 + "multibase", 224 + "multihash", 225 + "regex", 226 + "serde", 227 + ] 228 + 229 + [[package]] 230 + name = "memchr" 231 + version = "2.7.6" 232 + source = "registry+https://github.com/rust-lang/crates.io-index" 233 + checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" 234 + 235 + [[package]] 236 + name = "multibase" 237 + version = "0.9.1" 238 + source = "registry+https://github.com/rust-lang/crates.io-index" 239 + checksum = "9b3539ec3c1f04ac9748a260728e855f261b4977f5c3406612c884564f329404" 240 + dependencies = [ 241 + "base-x", 242 + "data-encoding", 243 + "data-encoding-macro", 244 + ] 245 + 246 + [[package]] 247 + name = "multihash" 248 + version = "0.19.3" 249 + source = "registry+https://github.com/rust-lang/crates.io-index" 250 + checksum = "6b430e7953c29dd6a09afc29ff0bb69c6e306329ee6794700aee27b76a1aea8d" 251 + dependencies = [ 252 + "core2", 253 + "unsigned-varint", 254 + ] 255 + 256 + [[package]] 121 257 name = "once_cell_polyfill" 122 258 version = "1.70.1" 123 259 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 142 278 ] 143 279 144 280 [[package]] 281 + name = "regex" 282 + version = "1.11.3" 283 + source = "registry+https://github.com/rust-lang/crates.io-index" 284 + checksum = "8b5288124840bee7b386bc413c487869b360b2b4ec421ea56425128692f2a82c" 285 + dependencies = [ 286 + "aho-corasick", 287 + "memchr", 288 + "regex-automata", 289 + "regex-syntax", 290 + ] 291 + 292 + [[package]] 293 + name = "regex-automata" 294 + version = "0.4.11" 295 + source = "registry+https://github.com/rust-lang/crates.io-index" 296 + checksum = "833eb9ce86d40ef33cb1306d8accf7bc8ec2bfea4355cbdebb3df68b40925cad" 297 + dependencies = [ 298 + "aho-corasick", 299 + "memchr", 300 + "regex-syntax", 301 + ] 302 + 303 + [[package]] 304 + name = "regex-syntax" 305 + version = "0.8.6" 306 + source = "registry+https://github.com/rust-lang/crates.io-index" 307 + checksum = "caf4aa5b0f434c91fe5c7f1ecb6a5ece2130b02ad2a590589dda5146df959001" 308 + 309 + [[package]] 310 + name = "rustversion" 311 + version = "1.0.22" 312 + source = "registry+https://github.com/rust-lang/crates.io-index" 313 + checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" 314 + 315 + [[package]] 316 + name = "ryu" 317 + version = "1.0.20" 318 + source = "registry+https://github.com/rust-lang/crates.io-index" 319 + checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" 320 + 321 + [[package]] 322 + name = "serde" 323 + version = "1.0.227" 324 + source = "registry+https://github.com/rust-lang/crates.io-index" 325 + checksum = "80ece43fc6fbed4eb5392ab50c07334d3e577cbf40997ee896fe7af40bba4245" 326 + dependencies = [ 327 + "serde_core", 328 + "serde_derive", 329 + ] 330 + 331 + [[package]] 332 + name = "serde_core" 333 + version = "1.0.227" 334 + source = "registry+https://github.com/rust-lang/crates.io-index" 335 + checksum = "7a576275b607a2c86ea29e410193df32bc680303c82f31e275bbfcafe8b33be5" 336 + dependencies = [ 337 + "serde_derive", 338 + ] 339 + 340 + [[package]] 341 + name = "serde_derive" 342 + version = "1.0.227" 343 + source = "registry+https://github.com/rust-lang/crates.io-index" 344 + checksum = "51e694923b8824cf0e9b382adf0f60d4e05f348f357b38833a3fa5ed7c2ede04" 345 + dependencies = [ 346 + "proc-macro2", 347 + "quote", 348 + "syn", 349 + ] 350 + 351 + [[package]] 352 + name = "static_assertions" 353 + version = "1.1.0" 354 + source = "registry+https://github.com/rust-lang/crates.io-index" 355 + checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" 356 + 357 + [[package]] 145 358 name = "strsim" 146 359 version = "0.11.1" 147 360 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 163 376 version = "1.0.19" 164 377 source = "registry+https://github.com/rust-lang/crates.io-index" 165 378 checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" 379 + 380 + [[package]] 381 + name = "unsigned-varint" 382 + version = "0.8.0" 383 + source = "registry+https://github.com/rust-lang/crates.io-index" 384 + checksum = "eb066959b24b5196ae73cb057f45598450d2c5f71460e98c49b738086eff9c06" 166 385 167 386 [[package]] 168 387 name = "utf8parse"
+4 -2
Cargo.toml
··· 4 4 5 5 6 6 [workspace.package] 7 - authors = ["Orual <orual@nonbinary.computer>"] 8 7 edition = "2024" 9 - description = "A simple Rust project using Nix" 10 8 version = "0.1.0" 9 + authors = ["Orual <orual@nonbinary.computer>"] 10 + 11 + description = "A simple Rust project using Nix" 12 + 11 13 12 14 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 13 15
+14
crates/jacquard-common/Cargo.toml
··· 1 + [package] 2 + name = "jacquard-common" 3 + edition.workspace = true 4 + version.workspace = true 5 + authors.workspace = true 6 + description.workspace = true 7 + 8 + [dependencies] 9 + cid = "0.11.1" 10 + compact_str = "0.9.0" 11 + multibase = "0.9.1" 12 + multihash = "0.19.3" 13 + regex = "1.11.3" 14 + serde = { version = "1.0.227", features = ["derive"] }
crates/jacquard-common/src/aturi.rs

This is a binary file and will not be displayed.

+5
crates/jacquard-common/src/blob.rs
··· 1 + use crate::CowStr; 2 + 3 + /// Wrapper for file type 4 + #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] 5 + pub struct MimeType<'m>(pub CowStr<'m>);
+20
crates/jacquard-common/src/cid.rs
··· 1 + use serde::{Deserialize, Serialize}; 2 + use std::str:: 3 + 4 + pub use cid::Cid as IpldCid; 5 + 6 + /// raw 7 + pub const ATP_CID_CODEC: u64 = 0x55; 8 + 9 + /// SHA-256 10 + pub const ATP_CID_HASH: u64 = 0x12; 11 + 12 + /// base 32 13 + pub const ATP_CID_BASE: multibase::Base = multibase::Base::Base32; 14 + 15 + #[derive(Serialize, Deserialize, Debug, Clone)] 16 + #[serde(untagged)] 17 + pub enum Cid { 18 + Cid(IpldCid), 19 + CidStr(CowStr<'static>), 20 + }
+285
crates/jacquard-common/src/cowstr.rs
··· 1 + use std::{ 2 + borrow::Cow, 3 + fmt, 4 + hash::{Hash, Hasher}, 5 + ops::Deref, 6 + }; 7 + 8 + use compact_str::CompactString; 9 + 10 + use crate::IntoStatic; 11 + 12 + /// Shamelessly copied from https://github.com/bearcove/merde 13 + /// A copy-on-write string type that uses [`CompactString`] for 14 + /// the "owned" variant. 15 + /// 16 + /// The standard [`Cow`] type cannot be used, since 17 + /// `<str as ToOwned>::Owned` is `String`, and not `CompactString`. 18 + #[derive(Clone)] 19 + pub enum CowStr<'s> { 20 + Borrowed(&'s str), 21 + Owned(CompactString), 22 + } 23 + 24 + impl CowStr<'static> { 25 + /// Create a new `CowStr` by copying from a `&str` — this might allocate 26 + /// if the `compact_str` feature is disabled, or if the string is longer 27 + /// than `MAX_INLINE_SIZE`. 28 + pub fn copy_from_str(s: &str) -> Self { 29 + Self::Owned(CompactString::from(s)) 30 + } 31 + } 32 + 33 + impl<'s> CowStr<'s> { 34 + #[inline] 35 + pub fn from_utf8(s: &'s [u8]) -> Result<Self, std::str::Utf8Error> { 36 + Ok(Self::Borrowed(std::str::from_utf8(s)?)) 37 + } 38 + 39 + #[inline] 40 + pub fn from_utf8_owned(s: Vec<u8>) -> Result<Self, std::str::Utf8Error> { 41 + Ok(Self::Owned(CompactString::from_utf8(s)?)) 42 + } 43 + 44 + #[inline] 45 + pub fn from_utf8_lossy(s: &'s [u8]) -> Self { 46 + Self::Owned(CompactString::from_utf8_lossy(s)) 47 + } 48 + 49 + /// # Safety 50 + /// 51 + /// This function is unsafe because it does not check that the bytes are valid UTF-8. 52 + #[inline] 53 + pub unsafe fn from_utf8_unchecked(s: &'s [u8]) -> Self { 54 + unsafe { Self::Owned(CompactString::from_utf8_unchecked(s)) } 55 + } 56 + } 57 + 58 + impl AsRef<str> for CowStr<'_> { 59 + #[inline] 60 + fn as_ref(&self) -> &str { 61 + match self { 62 + CowStr::Borrowed(s) => s, 63 + CowStr::Owned(s) => s.as_str(), 64 + } 65 + } 66 + } 67 + 68 + impl Deref for CowStr<'_> { 69 + type Target = str; 70 + 71 + #[inline] 72 + fn deref(&self) -> &Self::Target { 73 + match self { 74 + CowStr::Borrowed(s) => s, 75 + CowStr::Owned(s) => s.as_str(), 76 + } 77 + } 78 + } 79 + 80 + impl<'a> From<Cow<'a, str>> for CowStr<'a> { 81 + #[inline] 82 + fn from(s: Cow<'a, str>) -> Self { 83 + match s { 84 + Cow::Borrowed(s) => CowStr::Borrowed(s), 85 + #[allow(clippy::useless_conversion)] 86 + Cow::Owned(s) => CowStr::Owned(s.into()), 87 + } 88 + } 89 + } 90 + 91 + impl<'s> From<&'s str> for CowStr<'s> { 92 + #[inline] 93 + fn from(s: &'s str) -> Self { 94 + CowStr::Borrowed(s) 95 + } 96 + } 97 + 98 + impl From<String> for CowStr<'_> { 99 + #[inline] 100 + fn from(s: String) -> Self { 101 + #[allow(clippy::useless_conversion)] 102 + CowStr::Owned(s.into()) 103 + } 104 + } 105 + 106 + impl From<Box<str>> for CowStr<'_> { 107 + #[inline] 108 + fn from(s: Box<str>) -> Self { 109 + CowStr::Owned(s.into()) 110 + } 111 + } 112 + 113 + impl<'s> From<&'s String> for CowStr<'s> { 114 + #[inline] 115 + fn from(s: &'s String) -> Self { 116 + CowStr::Borrowed(s.as_str()) 117 + } 118 + } 119 + 120 + impl From<CowStr<'_>> for String { 121 + #[inline] 122 + fn from(s: CowStr<'_>) -> Self { 123 + match s { 124 + CowStr::Borrowed(s) => s.into(), 125 + #[allow(clippy::useless_conversion)] 126 + CowStr::Owned(s) => s.into(), 127 + } 128 + } 129 + } 130 + 131 + impl From<CowStr<'_>> for Box<str> { 132 + #[inline] 133 + fn from(s: CowStr<'_>) -> Self { 134 + match s { 135 + CowStr::Borrowed(s) => s.into(), 136 + CowStr::Owned(s) => s.into(), 137 + } 138 + } 139 + } 140 + 141 + impl<'a> PartialEq<CowStr<'a>> for CowStr<'_> { 142 + #[inline] 143 + fn eq(&self, other: &CowStr<'a>) -> bool { 144 + self.deref() == other.deref() 145 + } 146 + } 147 + 148 + impl PartialEq<&str> for CowStr<'_> { 149 + #[inline] 150 + fn eq(&self, other: &&str) -> bool { 151 + self.deref() == *other 152 + } 153 + } 154 + 155 + impl PartialEq<CowStr<'_>> for &str { 156 + #[inline] 157 + fn eq(&self, other: &CowStr<'_>) -> bool { 158 + *self == other.deref() 159 + } 160 + } 161 + 162 + impl PartialEq<String> for CowStr<'_> { 163 + #[inline] 164 + fn eq(&self, other: &String) -> bool { 165 + self.deref() == other.as_str() 166 + } 167 + } 168 + 169 + impl PartialEq<CowStr<'_>> for String { 170 + #[inline] 171 + fn eq(&self, other: &CowStr<'_>) -> bool { 172 + self.as_str() == other.deref() 173 + } 174 + } 175 + 176 + impl Eq for CowStr<'_> {} 177 + 178 + impl Hash for CowStr<'_> { 179 + #[inline] 180 + fn hash<H: Hasher>(&self, state: &mut H) { 181 + self.deref().hash(state) 182 + } 183 + } 184 + 185 + impl fmt::Debug for CowStr<'_> { 186 + #[inline] 187 + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 188 + self.deref().fmt(f) 189 + } 190 + } 191 + 192 + impl fmt::Display for CowStr<'_> { 193 + #[inline] 194 + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 195 + self.deref().fmt(f) 196 + } 197 + } 198 + 199 + impl IntoStatic for CowStr<'_> { 200 + type Output = CowStr<'static>; 201 + 202 + #[inline] 203 + fn into_static(self) -> Self::Output { 204 + match self { 205 + CowStr::Borrowed(s) => CowStr::Owned((*s).into()), 206 + CowStr::Owned(s) => CowStr::Owned(s), 207 + } 208 + } 209 + } 210 + 211 + use serde::{Deserialize, Serialize}; 212 + 213 + impl Serialize for CowStr<'_> { 214 + #[inline] 215 + fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> 216 + where 217 + S: serde::Serializer, 218 + { 219 + serializer.serialize_str(self) 220 + } 221 + } 222 + 223 + impl<'de: 'a, 'a> Deserialize<'de> for CowStr<'a> { 224 + #[inline] 225 + fn deserialize<D>(deserializer: D) -> Result<CowStr<'a>, D::Error> 226 + where 227 + D: serde::Deserializer<'de>, 228 + { 229 + struct CowStrVisitor; 230 + 231 + impl<'de> serde::de::Visitor<'de> for CowStrVisitor { 232 + type Value = CowStr<'de>; 233 + 234 + #[inline] 235 + fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 236 + write!(formatter, "a string") 237 + } 238 + 239 + #[inline] 240 + fn visit_str<E>(self, v: &str) -> Result<Self::Value, E> 241 + where 242 + E: serde::de::Error, 243 + { 244 + Ok(CowStr::copy_from_str(v)) 245 + } 246 + 247 + #[inline] 248 + fn visit_borrowed_str<E>(self, v: &'de str) -> Result<Self::Value, E> 249 + where 250 + E: serde::de::Error, 251 + { 252 + Ok(CowStr::Borrowed(v)) 253 + } 254 + 255 + #[inline] 256 + fn visit_string<E>(self, v: String) -> Result<Self::Value, E> 257 + where 258 + E: serde::de::Error, 259 + { 260 + Ok(v.into()) 261 + } 262 + } 263 + 264 + deserializer.deserialize_str(CowStrVisitor) 265 + } 266 + } 267 + 268 + #[cfg(test)] 269 + mod tests { 270 + use super::*; 271 + 272 + #[test] 273 + fn test_partialeq_with_str() { 274 + let cow_str1 = CowStr::Borrowed("hello"); 275 + let cow_str2 = CowStr::Borrowed("hello"); 276 + let cow_str3 = CowStr::Borrowed("world"); 277 + 278 + assert_eq!(cow_str1, "hello"); 279 + assert_eq!("hello", cow_str1); 280 + assert_eq!(cow_str1, cow_str2); 281 + assert_ne!(cow_str1, "world"); 282 + assert_ne!("world", cow_str1); 283 + assert_ne!(cow_str1, cow_str3); 284 + } 285 + }
+3
crates/jacquard-common/src/did.rs
··· 1 + use crate::CowStr; 2 + 3 + pub struct Did<'d>(CowStr<'d>);
crates/jacquard-common/src/handle.rs

This is a binary file and will not be displayed.

+291
crates/jacquard-common/src/into_static.rs
··· 1 + use std::borrow::Cow; 2 + use std::collections::HashMap; 3 + use std::collections::HashSet; 4 + use std::collections::VecDeque; 5 + use std::hash::BuildHasher; 6 + use std::hash::Hash; 7 + use std::sync::Arc; 8 + 9 + /// Shamelessly copied from https://github.com/bearcove/merde 10 + /// Allow turning a value into an "owned" variant, which can then be 11 + /// returned, moved, etc. 12 + /// 13 + /// This usually involves allocating buffers for `Cow<'a, str>`, etc. 14 + pub trait IntoStatic: Sized { 15 + /// The "owned" variant of the type. For `Cow<'a, str>`, this is `Cow<'static, str>`, for example. 16 + type Output: 'static; 17 + 18 + /// Turns the value into an "owned" variant, which can then be returned, moved, etc. 19 + /// 20 + /// This allocates, for all but the most trivial types. 21 + fn into_static(self) -> Self::Output; 22 + } 23 + 24 + impl<T, E> IntoStatic for Result<T, E> 25 + where 26 + T: IntoStatic, 27 + E: IntoStatic, 28 + { 29 + type Output = Result<T::Output, E::Output>; 30 + 31 + fn into_static(self) -> Self::Output { 32 + match self { 33 + Ok(v) => Ok(v.into_static()), 34 + Err(e) => Err(e.into_static()), 35 + } 36 + } 37 + } 38 + 39 + impl<T> IntoStatic for Cow<'_, T> 40 + where 41 + T: ToOwned + ?Sized + 'static, 42 + { 43 + type Output = Cow<'static, T>; 44 + 45 + #[inline(always)] 46 + fn into_static(self) -> Self::Output { 47 + match self { 48 + Cow::Borrowed(b) => Cow::Owned(b.to_owned()), 49 + Cow::Owned(o) => Cow::Owned(o), 50 + } 51 + } 52 + } 53 + 54 + macro_rules! impl_into_static_passthru { 55 + ($($ty:ty),+) => { 56 + $( 57 + impl IntoStatic for $ty { 58 + type Output = $ty; 59 + 60 + #[inline(always)] 61 + fn into_static(self) -> Self::Output { 62 + self 63 + } 64 + } 65 + )+ 66 + }; 67 + } 68 + 69 + impl_into_static_passthru!( 70 + String, u128, u64, u32, u16, u8, i128, i64, i32, i16, i8, bool, char, usize, isize, f32, f64 71 + ); 72 + 73 + impl<T: IntoStatic> IntoStatic for Box<T> { 74 + type Output = Box<T::Output>; 75 + 76 + fn into_static(self) -> Self::Output { 77 + Box::new((*self).into_static()) 78 + } 79 + } 80 + 81 + impl<T: IntoStatic> IntoStatic for Option<T> { 82 + type Output = Option<T::Output>; 83 + 84 + fn into_static(self) -> Self::Output { 85 + self.map(|v| v.into_static()) 86 + } 87 + } 88 + 89 + impl<T: IntoStatic> IntoStatic for Vec<T> { 90 + type Output = Vec<T::Output>; 91 + 92 + fn into_static(self) -> Self::Output { 93 + self.into_iter().map(|v| v.into_static()).collect() 94 + } 95 + } 96 + 97 + impl<T: IntoStatic + Clone> IntoStatic for Arc<T> { 98 + type Output = Arc<T::Output>; 99 + 100 + fn into_static(self) -> Self::Output { 101 + let t: T = (*self).clone(); 102 + Arc::new(t.into_static()) 103 + } 104 + } 105 + 106 + impl<K, V, S> IntoStatic for HashMap<K, V, S> 107 + where 108 + S: BuildHasher + Default + 'static, 109 + K: IntoStatic + Eq + Hash, 110 + V: IntoStatic, 111 + K::Output: Eq + Hash, 112 + { 113 + type Output = HashMap<K::Output, V::Output, S>; 114 + 115 + fn into_static(self) -> Self::Output { 116 + self.into_iter() 117 + .map(|(k, v)| (k.into_static(), v.into_static())) 118 + .collect() 119 + } 120 + } 121 + 122 + impl<T: IntoStatic> IntoStatic for HashSet<T> 123 + where 124 + T::Output: Eq + Hash, 125 + { 126 + type Output = HashSet<T::Output>; 127 + 128 + fn into_static(self) -> Self::Output { 129 + self.into_iter().map(|v| v.into_static()).collect() 130 + } 131 + } 132 + 133 + impl<T: IntoStatic> IntoStatic for VecDeque<T> { 134 + type Output = VecDeque<T::Output>; 135 + 136 + fn into_static(self) -> Self::Output { 137 + self.into_iter().map(|v| v.into_static()).collect() 138 + } 139 + } 140 + 141 + impl<T1: IntoStatic> IntoStatic for (T1,) { 142 + type Output = (T1::Output,); 143 + 144 + fn into_static(self) -> Self::Output { 145 + (self.0.into_static(),) 146 + } 147 + } 148 + 149 + impl<T1: IntoStatic, T2: IntoStatic> IntoStatic for (T1, T2) { 150 + type Output = (T1::Output, T2::Output); 151 + 152 + fn into_static(self) -> Self::Output { 153 + (self.0.into_static(), self.1.into_static()) 154 + } 155 + } 156 + 157 + impl<T1: IntoStatic, T2: IntoStatic, T3: IntoStatic> IntoStatic for (T1, T2, T3) { 158 + type Output = (T1::Output, T2::Output, T3::Output); 159 + 160 + fn into_static(self) -> Self::Output { 161 + ( 162 + self.0.into_static(), 163 + self.1.into_static(), 164 + self.2.into_static(), 165 + ) 166 + } 167 + } 168 + 169 + impl<T1: IntoStatic, T2: IntoStatic, T3: IntoStatic, T4: IntoStatic> IntoStatic 170 + for (T1, T2, T3, T4) 171 + { 172 + type Output = (T1::Output, T2::Output, T3::Output, T4::Output); 173 + 174 + fn into_static(self) -> Self::Output { 175 + ( 176 + self.0.into_static(), 177 + self.1.into_static(), 178 + self.2.into_static(), 179 + self.3.into_static(), 180 + ) 181 + } 182 + } 183 + 184 + impl<T1: IntoStatic, T2: IntoStatic, T3: IntoStatic, T4: IntoStatic, T5: IntoStatic> IntoStatic 185 + for (T1, T2, T3, T4, T5) 186 + { 187 + type Output = (T1::Output, T2::Output, T3::Output, T4::Output, T5::Output); 188 + 189 + fn into_static(self) -> Self::Output { 190 + ( 191 + self.0.into_static(), 192 + self.1.into_static(), 193 + self.2.into_static(), 194 + self.3.into_static(), 195 + self.4.into_static(), 196 + ) 197 + } 198 + } 199 + 200 + impl<T1: IntoStatic, T2: IntoStatic, T3: IntoStatic, T4: IntoStatic, T5: IntoStatic, T6: IntoStatic> 201 + IntoStatic for (T1, T2, T3, T4, T5, T6) 202 + { 203 + type Output = ( 204 + T1::Output, 205 + T2::Output, 206 + T3::Output, 207 + T4::Output, 208 + T5::Output, 209 + T6::Output, 210 + ); 211 + 212 + fn into_static(self) -> Self::Output { 213 + ( 214 + self.0.into_static(), 215 + self.1.into_static(), 216 + self.2.into_static(), 217 + self.3.into_static(), 218 + self.4.into_static(), 219 + self.5.into_static(), 220 + ) 221 + } 222 + } 223 + 224 + impl< 225 + T1: IntoStatic, 226 + T2: IntoStatic, 227 + T3: IntoStatic, 228 + T4: IntoStatic, 229 + T5: IntoStatic, 230 + T6: IntoStatic, 231 + T7: IntoStatic, 232 + > IntoStatic for (T1, T2, T3, T4, T5, T6, T7) 233 + { 234 + type Output = ( 235 + T1::Output, 236 + T2::Output, 237 + T3::Output, 238 + T4::Output, 239 + T5::Output, 240 + T6::Output, 241 + T7::Output, 242 + ); 243 + 244 + fn into_static(self) -> Self::Output { 245 + ( 246 + self.0.into_static(), 247 + self.1.into_static(), 248 + self.2.into_static(), 249 + self.3.into_static(), 250 + self.4.into_static(), 251 + self.5.into_static(), 252 + self.6.into_static(), 253 + ) 254 + } 255 + } 256 + 257 + impl< 258 + T1: IntoStatic, 259 + T2: IntoStatic, 260 + T3: IntoStatic, 261 + T4: IntoStatic, 262 + T5: IntoStatic, 263 + T6: IntoStatic, 264 + T7: IntoStatic, 265 + T8: IntoStatic, 266 + > IntoStatic for (T1, T2, T3, T4, T5, T6, T7, T8) 267 + { 268 + type Output = ( 269 + T1::Output, 270 + T2::Output, 271 + T3::Output, 272 + T4::Output, 273 + T5::Output, 274 + T6::Output, 275 + T7::Output, 276 + T8::Output, 277 + ); 278 + 279 + fn into_static(self) -> Self::Output { 280 + ( 281 + self.0.into_static(), 282 + self.1.into_static(), 283 + self.2.into_static(), 284 + self.3.into_static(), 285 + self.4.into_static(), 286 + self.5.into_static(), 287 + self.6.into_static(), 288 + self.7.into_static(), 289 + ) 290 + } 291 + }
+10
crates/jacquard-common/src/lib.rs
··· 1 + pub mod aturi; 2 + pub mod cowstr; 3 + pub mod did; 4 + pub mod handle; 5 + pub mod into_static; 6 + pub mod link; 7 + pub mod nsid; 8 + 9 + pub use cowstr::CowStr; 10 + pub use into_static::IntoStatic;
+1
crates/jacquard-common/src/link.rs
··· 1 + // strongref, blobref(s), cid links
crates/jacquard-common/src/nsid.rs

This is a binary file and will not be displayed.

+1
crates/jacquard/Cargo.toml
··· 4 4 name = "jacquard" 5 5 description = "A simple Rust project using Nix" 6 6 version.workspace = true 7 + edition.workspace = true 7 8 8 9 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 9 10
+21 -21
flake.lock
··· 17 17 }, 18 18 "crane": { 19 19 "locked": { 20 - "lastModified": 1736566337, 21 - "narHash": "sha256-SC0eDcZPqISVt6R0UfGPyQLrI0+BppjjtQ3wcSlk0oI=", 20 + "lastModified": 1757183466, 21 + "narHash": "sha256-kTdCCMuRE+/HNHES5JYsbRHmgtr+l9mOtf5dpcMppVc=", 22 22 "owner": "ipetkov", 23 23 "repo": "crane", 24 - "rev": "9172acc1ee6c7e1cbafc3044ff850c568c75a5a3", 24 + "rev": "d599ae4847e7f87603e7082d73ca673aa93c916d", 25 25 "type": "github" 26 26 }, 27 27 "original": { ··· 37 37 ] 38 38 }, 39 39 "locked": { 40 - "lastModified": 1725234343, 41 - "narHash": "sha256-+ebgonl3NbiKD2UD0x4BszCZQ6sTfL4xioaM49o5B3Y=", 40 + "lastModified": 1756770412, 41 + "narHash": "sha256-+uWLQZccFHwqpGqr2Yt5VsW/PbeJVTn9Dk6SHWhNRPw=", 42 42 "owner": "hercules-ci", 43 43 "repo": "flake-parts", 44 - "rev": "567b938d64d4b4112ee253b9274472dc3a346eb6", 44 + "rev": "4524271976b625a4a605beefd893f270620fd751", 45 45 "type": "github" 46 46 }, 47 47 "original": { ··· 53 53 "git-hooks": { 54 54 "flake": false, 55 55 "locked": { 56 - "lastModified": 1734425854, 57 - "narHash": "sha256-nzE5UbJ41aPEKf8R2ZFYtLkqPmF7EIUbNEdHMBLg0Ig=", 56 + "lastModified": 1758108966, 57 + "narHash": "sha256-ytw7ROXaWZ7OfwHrQ9xvjpUWeGVm86pwnEd1QhzawIo=", 58 58 "owner": "cachix", 59 59 "repo": "git-hooks.nix", 60 - "rev": "0ddd26d0925f618c3a5d85a4fa5eb1e23a09491d", 60 + "rev": "54df955a695a84cd47d4a43e08e1feaf90b1fd9b", 61 61 "type": "github" 62 62 }, 63 63 "original": { ··· 68 68 }, 69 69 "nixpkgs": { 70 70 "locked": { 71 - "lastModified": 1736693123, 72 - "narHash": "sha256-9lIfXCaBPwUA7FnfDnoH4gxxdOvXG78k6UlUw0+ZDxc=", 71 + "lastModified": 1758763312, 72 + "narHash": "sha256-puBMviZhYlqOdUUgEmMVJpXqC/ToEqSvkyZ30qQ09xM=", 73 73 "owner": "nixos", 74 74 "repo": "nixpkgs", 75 - "rev": "2fdec2c2e68b7b7845d1ea4e0894c63143e3261b", 75 + "rev": "e57b3b16ad8758fd681511a078f35c416a8cc939", 76 76 "type": "github" 77 77 }, 78 78 "original": { ··· 84 84 }, 85 85 "process-compose-flake": { 86 86 "locked": { 87 - "lastModified": 1724606023, 88 - "narHash": "sha256-rdGeNa/lCS8E1lXzPqgl+vZUUvnbEZT11Bqkx5jfYug=", 87 + "lastModified": 1758658658, 88 + "narHash": "sha256-y5GSCqlGe/uZzlocCPZcjc7Gj+mTq7m0P6xPGx88+No=", 89 89 "owner": "Platonic-Systems", 90 90 "repo": "process-compose-flake", 91 - "rev": "f6ce9481df9aec739e4e06b67492401a5bb4f0b1", 91 + "rev": "e968a94633788f5d9595d727f41c2baf0714be7b", 92 92 "type": "github" 93 93 }, 94 94 "original": { ··· 117 117 "rust-overlay": "rust-overlay" 118 118 }, 119 119 "locked": { 120 - "lastModified": 1736806612, 121 - "narHash": "sha256-WioA+Vk7suDK+Ek77rDlbuxV6WqwFt30JsKHrmDCSiU=", 120 + "lastModified": 1757862855, 121 + "narHash": "sha256-XPqlAQkx8rvG89nw+SbU6TiGVYPWdYIklPljdAyjp7w=", 122 122 "owner": "juspay", 123 123 "repo": "rust-flake", 124 - "rev": "b5f39885e2fcf137bfaf75decc077f9cca2bd984", 124 + "rev": "fa28d6e30b5d13014f24354dc49e717733fbb995", 125 125 "type": "github" 126 126 }, 127 127 "original": { ··· 138 138 ] 139 139 }, 140 140 "locked": { 141 - "lastModified": 1736700680, 142 - "narHash": "sha256-9gmWIb8xsycWHEYpd2SiVIAZnUULX6Y+IMMZBcDUCQU=", 141 + "lastModified": 1757730403, 142 + "narHash": "sha256-Jxl4OZRVsXs8JxEHUVQn3oPu6zcqFyGGKaFrlNgbzp0=", 143 143 "owner": "oxalica", 144 144 "repo": "rust-overlay", 145 - "rev": "5d1865c0da63b4c949f383d982b6b43519946e8f", 145 + "rev": "3232f7f8bd07849fc6f4ae77fe695e0abb2eba2c", 146 146 "type": "github" 147 147 }, 148 148 "original": {
+11
nix/modules/rust.nix
··· 46 46 }; 47 47 }; 48 48 }; 49 + 50 + "jacquard-common" = { 51 + imports = [globalCrateConfig]; 52 + autoWire = ["crate" "clippy"]; 53 + path = ./../../crates/jacquard-common; 54 + crane = { 55 + args = { 56 + buildInputs = commonBuildInputs; 57 + }; 58 + }; 59 + }; 49 60 }; 50 61 }; 51 62 packages.default = self'.packages.jacquard;