viewpoint_core/page/aria_snapshot/options.rs
1//! Configuration options for ARIA snapshot capture.
2
3/// Default maximum number of concurrent CDP calls for node resolution.
4pub const DEFAULT_MAX_CONCURRENCY: usize = 50;
5
6/// Configuration options for ARIA snapshot capture.
7///
8/// Use this struct to tune snapshot performance and behavior.
9///
10/// # Example
11///
12/// ```no_run
13/// use viewpoint_core::SnapshotOptions;
14///
15/// // Default options
16/// let options = SnapshotOptions::default();
17///
18/// // Skip ref resolution for faster snapshots
19/// let options = SnapshotOptions::default().include_refs(false);
20///
21/// // Increase concurrency for fast networks
22/// let options = SnapshotOptions::default().max_concurrency(100);
23/// ```
24#[derive(Debug, Clone)]
25pub struct SnapshotOptions {
26 /// Maximum number of concurrent CDP calls for node resolution.
27 ///
28 /// Higher values improve performance but may overwhelm slow connections.
29 /// Default: 50
30 pub(crate) max_concurrency: usize,
31
32 /// Whether to include element refs (backendNodeIds) in the snapshot.
33 ///
34 /// Set to `false` to skip ref resolution for maximum performance when
35 /// you only need the accessibility tree structure.
36 /// Default: true
37 pub(crate) include_refs: bool,
38}
39
40impl Default for SnapshotOptions {
41 fn default() -> Self {
42 Self {
43 max_concurrency: DEFAULT_MAX_CONCURRENCY,
44 include_refs: true,
45 }
46 }
47}
48
49impl SnapshotOptions {
50 /// Set the maximum number of concurrent CDP calls for node resolution.
51 ///
52 /// Higher values improve performance but may overwhelm slow connections.
53 /// Default: 50
54 #[must_use]
55 pub fn max_concurrency(mut self, max: usize) -> Self {
56 self.max_concurrency = max;
57 self
58 }
59
60 /// Set whether to include element refs (backendNodeIds) in the snapshot.
61 ///
62 /// Set to `false` to skip ref resolution for maximum performance when
63 /// you only need the accessibility tree structure.
64 /// Default: true
65 #[must_use]
66 pub fn include_refs(mut self, include: bool) -> Self {
67 self.include_refs = include;
68 self
69 }
70
71 /// Get the maximum concurrency setting.
72 pub fn get_max_concurrency(&self) -> usize {
73 self.max_concurrency
74 }
75
76 /// Get whether refs should be included.
77 pub fn get_include_refs(&self) -> bool {
78 self.include_refs
79 }
80}