1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/// Bluesky actor preferences implementation
pub use PreferencesUpdate;
use IntoStatic;
use ;
/// Trait for get-modify-put patterns on vec-based data structures.
///
/// This trait enables convenient update operations for endpoints that return arrays
/// that need to be fetched, modified, and put back. Common use cases include
/// preferences, saved feeds, and similar collection-style data.
///
/// # Example
///
/// ```ignore
/// use jacquard::client::vec_update::VecUpdate;
///
/// struct PreferencesUpdate;
///
/// impl VecUpdate for PreferencesUpdate {
/// type GetRequest = GetPreferences;
/// type PutRequest = PutPreferences;
/// type Item = PreferencesItem<'static>;
///
/// fn extract_vec(output: GetPreferencesOutput<'_>) -> Vec<Self::Item> {
/// output.preferences.into_iter().map(|p| p.into_static()).collect()
/// }
///
/// fn build_put(items: Vec<Self::Item>) -> PutPreferences {
/// PutPreferences { preferences: items }
/// }
///
/// fn matches(a: &Self::Item, b: &Self::Item) -> bool {
/// // Match by enum variant discriminant
/// std::mem::discriminant(a) == std::mem::discriminant(b)
/// }
/// }
/// ```