Debian Codegraph @

third_party/rust/pulse/src/operation.rs

raw
1 // Copyright © 2017 Mozilla Foundation
2 //
3 // This program is made available under an ISC-style license. See the
4 // accompanying file LICENSE for details.
5
6 use ffi;
7
8 #[derive(Debug)]
9 pub struct Operation(*mut ffi::pa_operation);
10
11 impl Operation {
12 pub unsafe fn from_raw_ptr(raw: *mut ffi::pa_operation) -> Operation {
13 Operation(raw)
14 }
15
16 pub fn cancel(&mut self) {
17 unsafe {
18 ffi::pa_operation_cancel(self.0);
19 }
20 }
21
22 pub fn get_state(&self) -> ffi::pa_operation_state_t {
23 unsafe { ffi::pa_operation_get_state(self.0) }
24 }
25 }
26
27 impl Clone for Operation {
28 fn clone(&self) -> Self {
29 Operation(unsafe { ffi::pa_operation_ref(self.0) })
30 }
31 }
32
33 impl Drop for Operation {
34 fn drop(&mut self) {
35 unsafe {
36 ffi::pa_operation_unref(self.0);
37 }
38 }
39 }
40
41 pub unsafe fn from_raw_ptr(raw: *mut ffi::pa_operation) -> Operation {
42 Operation::from_raw_ptr(raw)
43 }