opencv_binding_generator/settings/
property_tweaks.rs1use std::collections::HashMap;
2
3use crate::SupportedModule;
4
5pub type PropertyTweaks = HashMap<&'static str, PropertyTweak<'static>>;
6
7#[derive(Debug)]
8pub struct PropertyTweak<'l> {
9 pub rename: Option<&'l str>,
10 pub read_write: Option<PropertyReadWrite>,
11}
12
13pub fn property_tweaks_factory(module: SupportedModule) -> PropertyTweaks {
15 match module {
16 SupportedModule::Core => HashMap::from([
17 (
18 "cv::Mat::size",
19 PropertyTweak {
20 rename: Some("mat_size"),
21 ..PropertyTweak::none()
22 },
23 ),
24 (
25 "cv::Mat::step",
26 PropertyTweak {
27 rename: Some("mat_step"),
28 read_write: Some(PropertyReadWrite::ReadOnly), },
30 ),
31 (
32 "cv::UMat::size",
33 PropertyTweak {
34 rename: Some("mat_size"),
35 ..PropertyTweak::none()
36 },
37 ),
38 (
39 "cv::UMat::step",
40 PropertyTweak {
41 rename: Some("mat_step"),
42 read_write: Some(PropertyReadWrite::ReadOnly), },
44 ),
45 ]),
46 _ => HashMap::new(),
47 }
48}
49
50impl PropertyTweak<'_> {
51 pub fn none() -> PropertyTweak<'static> {
52 PropertyTweak {
53 rename: None,
54 read_write: None,
55 }
56 }
57}
58
59#[derive(Clone, Copy, Debug)]
60pub enum PropertyReadWrite {
61 ReadOnly,
62 ReadWrite,
63}
64
65impl PropertyReadWrite {
66 pub fn is_read(self) -> bool {
67 match self {
68 PropertyReadWrite::ReadOnly | PropertyReadWrite::ReadWrite => true,
69 }
70 }
71
72 pub fn is_write(self) -> bool {
73 match self {
74 PropertyReadWrite::ReadWrite => true,
75 PropertyReadWrite::ReadOnly => false,
76 }
77 }
78}