aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bluetoothcharacteristicproperties.rs
blob: 9abb5e5cd5b7df29a29f4274444b15f04fdd6219 (plain) (blame)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding;
use dom::bindings::codegen::Bindings::BluetoothCharacteristicPropertiesBinding::
    BluetoothCharacteristicPropertiesMethods;
use dom::bindings::global::GlobalRef;
use dom::bindings::js::Root;
use dom::bindings::reflector::{Reflector, reflect_dom_object};

// https://webbluetoothcg.github.io/web-bluetooth/#characteristicproperties
 #[dom_struct]
pub struct BluetoothCharacteristicProperties {
    reflector_: Reflector,
    broadcast: bool,
    read: bool,
    writeWithoutResponse: bool,
    write: bool,
    notify: bool,
    indicate: bool,
    authenticatedSignedWrites: bool,
    reliableWrite: bool,
    writableAuxiliaries: bool,
}

impl BluetoothCharacteristicProperties {
    pub fn new_inherited(broadcast: bool,
                         read: bool,
                         writeWithoutResponse: bool,
                         write: bool,
                         notify: bool,
                         indicate: bool,
                         authenticatedSignedWrites: bool,
                         reliableWrite: bool,
                         writableAuxiliaries: bool)
                         -> BluetoothCharacteristicProperties {
        BluetoothCharacteristicProperties {
            reflector_: Reflector::new(),
            broadcast: broadcast,
            read: read,
            writeWithoutResponse: writeWithoutResponse,
            write: write,
            notify: notify,
            indicate: indicate,
            authenticatedSignedWrites: authenticatedSignedWrites,
            reliableWrite: reliableWrite,
            writableAuxiliaries: writableAuxiliaries,
        }
    }

    pub fn new(global: GlobalRef,
               broadcast: bool,
               read: bool,
               writeWithoutResponse: bool,
               write: bool,
               notify: bool,
               indicate: bool,
               authenticatedSignedWrites: bool,
               reliableWrite: bool,
               writableAuxiliaries: bool)
               -> Root<BluetoothCharacteristicProperties> {
        reflect_dom_object(box BluetoothCharacteristicProperties::new_inherited(broadcast,
                                                                                read,
                                                                                writeWithoutResponse,
                                                                                write,
                                                                                notify,
                                                                                indicate,
                                                                                authenticatedSignedWrites,
                                                                                reliableWrite,
                                                                                writableAuxiliaries),
                           global,
                           BluetoothCharacteristicPropertiesBinding::Wrap)
        }
    }

impl BluetoothCharacteristicPropertiesMethods for BluetoothCharacteristicProperties {
    // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-broadcast
    fn Broadcast(&self) -> bool {
        self.broadcast
    }

    // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-read
    fn Read(&self) -> bool {
        self.read
    }

    // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-writewithoutresponse
    fn WriteWithoutResponse(&self) -> bool {
        self.writeWithoutResponse
    }

    // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-write
    fn Write(&self) -> bool {
        self.write
    }

    // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-notify
    fn Notify(&self) -> bool {
        self.notify
    }

    // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-indicate
    fn Indicate(&self) -> bool {
        self.indicate
    }

    // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-authenticatedsignedwrites
    fn AuthenticatedSignedWrites(&self) -> bool {
        self.authenticatedSignedWrites
    }

    // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-reliablewrite
    fn ReliableWrite(&self) -> bool {
        self.reliableWrite
    }

    // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothcharacteristicproperties-writableauxiliaries
    fn WritableAuxiliaries(&self) -> bool {
        self.writableAuxiliaries
    }
}