Skip to main content

wsi_rs/core/registry/
open_options.rs

1use super::*;
2
3#[non_exhaustive]
4pub struct SlideOpenOptions {
5    pub(super) registry: FormatRegistry,
6    pub(super) cache_config: CacheConfig,
7    pub(super) svcache_policy: crate::formats::svcache::SvcachePolicy,
8    pub(super) max_region_pixels: u64,
9    pub(super) decode_execution_options: DecodeExecutionOptions,
10}
11
12impl SlideOpenOptions {
13    pub fn deterministic() -> Self {
14        Self {
15            registry: FormatRegistry::builtin(),
16            cache_config: CacheConfig::deterministic(),
17            svcache_policy: crate::formats::svcache::SvcachePolicy::Off,
18            max_region_pixels: DEFAULT_MAX_REGION_PIXELS,
19            decode_execution_options: DecodeExecutionOptions::default(),
20        }
21    }
22
23    pub fn with_cache_config(mut self, cache_config: CacheConfig) -> Self {
24        self.cache_config = cache_config;
25        self
26    }
27
28    pub fn with_svcache_policy(
29        mut self,
30        svcache_policy: crate::formats::svcache::SvcachePolicy,
31    ) -> Self {
32        self.svcache_policy = svcache_policy;
33        self
34    }
35
36    pub fn with_registry(mut self, registry: FormatRegistry) -> Self {
37        self.registry = registry;
38        self
39    }
40
41    pub fn with_max_region_pixels(mut self, max_region_pixels: u64) -> Self {
42        self.max_region_pixels = max_region_pixels;
43        self
44    }
45
46    pub fn with_decode_execution_options(
47        mut self,
48        decode_execution_options: DecodeExecutionOptions,
49    ) -> Self {
50        self.decode_execution_options = decode_execution_options;
51        self
52    }
53
54    pub fn cache_config(&self) -> CacheConfig {
55        self.cache_config
56    }
57
58    pub fn svcache_policy(&self) -> crate::formats::svcache::SvcachePolicy {
59        self.svcache_policy
60    }
61
62    pub fn max_region_pixels(&self) -> u64 {
63        self.max_region_pixels
64    }
65
66    pub fn decode_execution_options(&self) -> DecodeExecutionOptions {
67        self.decode_execution_options
68    }
69}
70
71impl Default for SlideOpenOptions {
72    fn default() -> Self {
73        Self::deterministic()
74    }
75}