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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//! Apple **App Clip Code**: the circular five-ring code iOS scans to launch an App
//! Clip.
//!
//! Apple has never published this format; everything here follows the public
//! reverse engineering of Apple's `AppClipCodeGenerator` and
//! `URLCompression.framework` ([rs/appclipcode], MIT), which this module reimplements
//! from scratch in Rust. The trained Huffman frequency tables in `data/` are byte
//! dumps of the framework's models (~1.7 MB), which is why the whole module sits
//! behind the default-on `appclip` cargo feature — lean builds can opt out with
//! `default-features = false`.
//!
//! # Format in one paragraph
//!
//! An HTTPS URL is compressed to at most 128 bits by multi-context Huffman coders
//! (trained tries for hosts and paths, TLD tables, a path wordbook, LEB128 numerics),
//! split into two Reed–Solomon-protected blocks plus a GF(16) metadata block,
//! scrambled, permuted through a fixed 128-entry LUT and laid out on five concentric
//! rings of 17/23/26/29/33 positions: the first 128 bits choose which positions carry
//! an arc versus a gap, and the remaining bits color each visible arc in either the
//! foreground or a derived third color. See `doc/SPEC.md` of [rs/appclipcode] for the
//! full write-up.
//!
//! Encoding, structural decoding (bits → URL) and camera detection ([`scan`], a
//! grayscale ring detector + sampler over a [`crate::image::GrayFrame`]) are all
//! implemented; [`crate::pipeline::scan_2d`] runs the detector automatically.
//!
//! [rs/appclipcode]: https://github.com/rs/appclipcode
//!
//! # Example
//!
//! ```
//! # #[cfg(feature = "appclip")] {
//! use anyd::codes::appclip;
//!
//! let svg = appclip::generate_svg("https://example.com", &appclip::Options::default()).unwrap();
//! assert!(svg.contains("data-design=\"Fingerprint\""));
//!
//! // Structural round-trip: bits back to the URL.
//! let payload = appclip::compress_url("https://example.com").unwrap();
//! let bits = appclip::encode_payload(&payload).unwrap();
//! let back = appclip::decode_payload(&bits).unwrap();
//! assert_eq!(appclip::decompress_url(&back).unwrap(), "https://example.com");
//! # }
//! ```
pub use ;
pub use scan;
pub use ;
pub use ;
use crateResult;
/// Generation options: colors and the center glyph.
/// Generate the SVG for `url`. The URL must be HTTPS and compressible to 128 bits —
/// short hosts and common path shapes fit; arbitrary long URLs may not.
/// Decode a full ring bit vector (gap bits + color stream) back to its URL.