+1
Cargo.lock
+1
Cargo.lock
+1
-1
crates/jacquard-api/Cargo.toml
+1
-1
crates/jacquard-api/Cargo.toml
+7
crates/jacquard-api/src/lib.rs
+7
crates/jacquard-api/src/lib.rs
···
3
// This file was automatically generated from Lexicon schemas.
4
// Any manual changes will be overwritten on the next regeneration.
5
6
+
#[cfg(feature = "app_bsky")]
7
pub mod app_bsky;
8
+
9
+
#[cfg(feature = "chat_bsky")]
10
pub mod chat_bsky;
11
+
12
+
#[cfg(feature = "com_atproto")]
13
pub mod com_atproto;
14
+
15
+
#[cfg(feature = "tools_ozone")]
16
pub mod tools_ozone;
+1
-1
crates/jacquard-common/src/cowstr.rs
+1
-1
crates/jacquard-common/src/cowstr.rs
+1
-1
crates/jacquard-common/src/into_static.rs
+1
-1
crates/jacquard-common/src/into_static.rs
+1
-1
crates/jacquard-common/src/types/aturi.rs
+1
-1
crates/jacquard-common/src/types/aturi.rs
+2
-2
crates/jacquard-common/src/types/collection.rs
+2
-2
crates/jacquard-common/src/types/collection.rs
···
26
///
27
/// Panics if [`Self::NSID`] is not a valid NSID.
28
///
29
-
/// [`Nsid`]: string::Nsid
30
fn nsid() -> crate::types::nsid::Nsid<'static> {
31
Nsid::new_static(Self::NSID).expect("should be valid NSID")
32
}
···
39
/// > [`RecordKey`].
40
///
41
/// [Repo Data Structure v3]: https://atproto.com/specs/repository#repo-data-structure-v3
42
-
/// [`Nsid`]: string::Nsid
43
fn repo_path<'u, T: RecordKeyType>(
44
rkey: &'u crate::types::recordkey::RecordKey<T>,
45
) -> UriPath<'u> {
···
26
///
27
/// Panics if [`Self::NSID`] is not a valid NSID.
28
///
29
+
/// [`Nsid`]: crate::types::string::Nsid
30
fn nsid() -> crate::types::nsid::Nsid<'static> {
31
Nsid::new_static(Self::NSID).expect("should be valid NSID")
32
}
···
39
/// > [`RecordKey`].
40
///
41
/// [Repo Data Structure v3]: https://atproto.com/specs/repository#repo-data-structure-v3
42
+
/// [`Nsid`]: crate::types::string::Nsid
43
fn repo_path<'u, T: RecordKeyType>(
44
rkey: &'u crate::types::recordkey::RecordKey<T>,
45
) -> UriPath<'u> {
+1
-1
crates/jacquard-common/src/types/did.rs
+1
-1
crates/jacquard-common/src/types/did.rs
···
76
/// Infallible constructor for when you *know* the string is a valid DID.
77
/// Will panic on invalid DIDs. If you're manually decoding atproto records
78
/// or API values you know are valid (rather than using serde), this is the one to use.
79
-
/// The From<String> and From<CowStr> impls use the same logic.
80
pub fn raw(did: &'d str) -> Self {
81
let did = did.strip_prefix("at://").unwrap_or(did);
82
if did.len() > 2048 {
···
76
/// Infallible constructor for when you *know* the string is a valid DID.
77
/// Will panic on invalid DIDs. If you're manually decoding atproto records
78
/// or API values you know are valid (rather than using serde), this is the one to use.
79
+
/// The `From<String>` and `From<CowStr>` impls use the same logic.
80
pub fn raw(did: &'d str) -> Self {
81
let did = did.strip_prefix("at://").unwrap_or(did);
82
if did.len() > 2048 {
+1
-1
crates/jacquard-common/src/types/handle.rs
+1
-1
crates/jacquard-common/src/types/handle.rs
···
95
/// Infallible constructor for when you *know* the string is a valid handle.
96
/// Will panic on invalid handles. If you're manually decoding atproto records
97
/// or API values you know are valid (rather than using serde), this is the one to use.
98
-
/// The From<String> and From<CowStr> impls use the same logic.
99
///
100
/// Accepts (and strips) preceding '@' or 'at://' if present
101
pub fn raw(handle: &'h str) -> Self {
···
95
/// Infallible constructor for when you *know* the string is a valid handle.
96
/// Will panic on invalid handles. If you're manually decoding atproto records
97
/// or API values you know are valid (rather than using serde), this is the one to use.
98
+
/// The `From<String>` and `From<CowStr>` impls use the same logic.
99
///
100
/// Accepts (and strips) preceding '@' or 'at://' if present
101
pub fn raw(handle: &'h str) -> Self {
+1
-1
crates/jacquard-common/src/types/ident.rs
+1
-1
crates/jacquard-common/src/types/ident.rs
···
49
/// Infallible constructor for when you *know* the string is a valid identifier.
50
/// Will panic on invalid identifiers. If you're manually decoding atproto records
51
/// or API values you know are valid (rather than using serde), this is the one to use.
52
-
/// The From<String> and From<CowStr> impls use the same logic.
53
pub fn raw(ident: &'i str) -> Self {
54
if let Ok(did) = ident.parse() {
55
AtIdentifier::Did(did)
···
49
/// Infallible constructor for when you *know* the string is a valid identifier.
50
/// Will panic on invalid identifiers. If you're manually decoding atproto records
51
/// or API values you know are valid (rather than using serde), this is the one to use.
52
+
/// The `From<String>` and `From<CowStr>` impls use the same logic.
53
pub fn raw(ident: &'i str) -> Self {
54
if let Ok(did) = ident.parse() {
55
AtIdentifier::Did(did)
+1
-1
crates/jacquard-common/src/types/language.rs
+1
-1
crates/jacquard-common/src/types/language.rs
···
34
/// Infallible constructor for when you *know* the string is a valid IETF language tag.
35
/// Will panic on invalid tag. If you're manually decoding atproto records
36
/// or API values you know are valid (rather than using serde), this is the one to use.
37
-
/// The From<String> and From<CowStr> impls use the same logic.
38
pub fn raw(lang: impl AsRef<str>) -> Self {
39
let lang = lang.as_ref();
40
let tag = langtag::LangTag::new(lang).expect("valid IETF language tag");
···
34
/// Infallible constructor for when you *know* the string is a valid IETF language tag.
35
/// Will panic on invalid tag. If you're manually decoding atproto records
36
/// or API values you know are valid (rather than using serde), this is the one to use.
37
+
/// The `From<String>` and `From<CowStr>` impls use the same logic.
38
pub fn raw(lang: impl AsRef<str>) -> Self {
39
let lang = lang.as_ref();
40
let tag = langtag::LangTag::new(lang).expect("valid IETF language tag");
+1
-1
crates/jacquard-common/src/types/nsid.rs
+1
-1
crates/jacquard-common/src/types/nsid.rs
···
71
/// Infallible constructor for when you *know* the string is a valid NSID.
72
/// Will panic on invalid NSIDs. If you're manually decoding atproto records
73
/// or API values you know are valid (rather than using serde), this is the one to use.
74
-
/// The From<String> and From<CowStr> impls use the same logic.
75
pub fn raw(nsid: &'n str) -> Self {
76
if nsid.len() > 317 {
77
panic!("NSID too long")
···
71
/// Infallible constructor for when you *know* the string is a valid NSID.
72
/// Will panic on invalid NSIDs. If you're manually decoding atproto records
73
/// or API values you know are valid (rather than using serde), this is the one to use.
74
+
/// The `From<String>` and `From<CowStr>` impls use the same logic.
75
pub fn raw(nsid: &'n str) -> Self {
76
if nsid.len() > 317 {
77
panic!("NSID too long")
+3
-3
crates/jacquard-common/src/types/recordkey.rs
+3
-3
crates/jacquard-common/src/types/recordkey.rs
···
14
/// This is deliberately public (so that consumers can develop specialized record key types),
15
/// but is marked as unsafe, because the implementer is expected to uphold the invariants
16
/// required by this trait, namely compliance with the [spec](https://atproto.com/specs/record-key)
17
-
/// as described by [`RKEY_REGEX`](RKEY_REGEX).
18
///
19
/// This crate provides implementations for TID, NSID, literals, and generic strings
20
pub unsafe trait RecordKeyType: Clone + Serialize {
···
57
}
58
59
/// ATProto Record Key (type `any`)
60
-
/// Catch-all for any string meeting the overall Record Key requirements detailed https://atproto.com/specs/record-key
61
#[derive(Clone, PartialEq, Eq, Serialize, Hash)]
62
#[serde(transparent)]
63
#[repr(transparent)]
···
298
/// Infallible constructor for when you *know* the string is a valid rkey.
299
/// Will panic on invalid rkeys. If you're manually decoding atproto records
300
/// or API values you know are valid (rather than using serde), this is the one to use.
301
-
/// The From<String> and From<CowStr> impls use the same logic.
302
pub fn raw(rkey: &str) -> Self {
303
if !rkey.eq_ignore_ascii_case(T::LITERAL) {
304
panic!(
···
14
/// This is deliberately public (so that consumers can develop specialized record key types),
15
/// but is marked as unsafe, because the implementer is expected to uphold the invariants
16
/// required by this trait, namely compliance with the [spec](https://atproto.com/specs/record-key)
17
+
/// as described by [`RKEY_REGEX`].
18
///
19
/// This crate provides implementations for TID, NSID, literals, and generic strings
20
pub unsafe trait RecordKeyType: Clone + Serialize {
···
57
}
58
59
/// ATProto Record Key (type `any`)
60
+
/// Catch-all for any string meeting the overall Record Key requirements detailed [](https://atproto.com/specs/record-key)
61
#[derive(Clone, PartialEq, Eq, Serialize, Hash)]
62
#[serde(transparent)]
63
#[repr(transparent)]
···
298
/// Infallible constructor for when you *know* the string is a valid rkey.
299
/// Will panic on invalid rkeys. If you're manually decoding atproto records
300
/// or API values you know are valid (rather than using serde), this is the one to use.
301
+
/// The `From<String>` and `From<CowStr>` impls use the same logic.
302
pub fn raw(rkey: &str) -> Self {
303
if !rkey.eq_ignore_ascii_case(T::LITERAL) {
304
panic!(
+1
-1
crates/jacquard-common/src/types/tid.rs
+1
-1
crates/jacquard-common/src/types/tid.rs
···
71
/// Infallible constructor for when you *know* the string is a valid TID.
72
/// Will panic on invalid TID. If you're manually decoding atproto records
73
/// or API values you know are valid (rather than using serde), this is the one to use.
74
-
/// The From<String> and From<CowStr> impls use the same logic.
75
pub fn raw(tid: impl AsRef<str>) -> Self {
76
let tid = tid.as_ref();
77
if tid.len() != 13 {
···
71
/// Infallible constructor for when you *know* the string is a valid TID.
72
/// Will panic on invalid TID. If you're manually decoding atproto records
73
/// or API values you know are valid (rather than using serde), this is the one to use.
74
+
/// The `From<String>` and `From<CowStr>` impls use the same logic.
75
pub fn raw(tid: impl AsRef<str>) -> Self {
76
let tid = tid.as_ref();
77
if tid.len() != 13 {
+10
-1
crates/jacquard-lexicon/src/codegen.rs
+10
-1
crates/jacquard-lexicon/src/codegen.rs
···
1089
path
1090
};
1091
1092
+
let is_root = dir.components().count() == 0;
1093
let mods: Vec<_> = module_names
1094
.iter()
1095
.map(|name| {
1096
let ident = syn::Ident::new(name, proc_macro2::Span::call_site());
1097
+
if is_root {
1098
+
// Top-level modules get feature gates
1099
+
quote! {
1100
+
#[cfg(feature = #name)]
1101
+
pub mod #ident;
1102
+
}
1103
+
} else {
1104
+
quote! { pub mod #ident; }
1105
+
}
1106
})
1107
.collect();
1108
+6
-1
crates/jacquard/Cargo.toml
+6
-1
crates/jacquard/Cargo.toml
···
6
version.workspace = true
7
edition.workspace = true
8
9
-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
10
11
[lib]
12
name = "jacquard"
···
22
http = "1.3.1"
23
jacquard-api = { version = "0.1.0", path = "../jacquard-api" }
24
jacquard-common = { path = "../jacquard-common" }
25
miette = "7.6.0"
26
reqwest = { version = "0.12.23", default-features = false, features = ["charset", "http2", "json", "system-proxy", "gzip", "rustls-tls"] }
27
serde = { version = "1.0", features = ["derive"] }
···
6
version.workspace = true
7
edition.workspace = true
8
9
+
[features]
10
+
default = ["api_all"]
11
+
derive = ["dep:jacquard-derive"]
12
+
api = ["jacquard-api/com_atproto"]
13
+
api_all = ["api", "jacquard-api/app_bsky", "jacquard-api/chat_bsky", "jacquard-api/tools_ozone"]
14
15
[lib]
16
name = "jacquard"
···
26
http = "1.3.1"
27
jacquard-api = { version = "0.1.0", path = "../jacquard-api" }
28
jacquard-common = { path = "../jacquard-common" }
29
+
jacquard-derive = { path = "../jacquard-derive", optional = true }
30
miette = "7.6.0"
31
reqwest = { version = "0.12.23", default-features = false, features = ["charset", "http2", "json", "system-proxy", "gzip", "rustls-tls"] }
32
serde = { version = "1.0", features = ["derive"] }
+5
crates/jacquard/src/lib.rs
+5
crates/jacquard/src/lib.rs