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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::ffi;
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
/// An event listener for node in IEEE 1394 bus.
///
/// [`FwNode`][crate::FwNode] listens to any events for an associated node in IEEE 1394 bus. Additionally,
/// it provides some methods to retrieve fundamental information about the bus.
///
/// ## Properties
///
///
/// #### `bus-manager-node-id`
/// Node ID of node which plays role of bus manager at current generation of bus topology.
///
/// Readable
///
///
/// #### `card-id`
/// The numeric index for 1394 OHCI hardware used for the communication with the node. The
/// value is stable against bus generation.
///
/// Readable
///
///
/// #### `generation`
/// Current generation of bus topology.
///
/// Readable
///
///
/// #### `ir-manager-node-id`
/// Node ID of node which plays role of isochronous resource manager at current generation
/// of bus topology.
///
/// Readable
///
///
/// #### `local-node-id`
/// Node ID of node which application uses to communicate to node associated to instance of
/// object at current generation of bus topology. In general, it is for 1394 OHCI hardware.
///
/// Readable
///
///
/// #### `node-id`
/// Node ID of node associated to instance of object at current generation of bus topology.
/// This parameter is effective after the association.
///
/// Readable
///
///
/// #### `root-node-id`
/// Node ID of root node in bus topology at current generation of bus topology.
///
/// Readable
///
/// ## Signals
///
///
/// #### `bus-update`
/// Emitted when IEEE 1394 bus is updated. Handlers can read current generation in the bus
/// via [`generation`][struct@crate::FwNode#generation] property.
///
///
///
///
/// #### `disconnected`
/// Emitted when the node is not available anymore in Linux system. It's preferable to call
/// `GObject::Object::unref()` immediately to release file descriptor.
///
///
///
/// # Implements
///
/// [`FwNodeExt`][trait@crate::prelude::FwNodeExt], [`FwNodeExtManual`][trait@crate::prelude::FwNodeExtManual]
#[doc(alias = "HinawaFwNode")]
pub struct FwNode(Object<ffi::HinawaFwNode, ffi::HinawaFwNodeClass>);
match fn {
type_ => || ffi::hinawa_fw_node_get_type(),
}
}
impl FwNode {
pub const NONE: Option<&'static FwNode> = None;
/// Instantiate [`FwNode`][crate::FwNode] object and return the instance.
///
/// # Returns
///
/// an instance of [`FwNode`][crate::FwNode].
#[doc(alias = "hinawa_fw_node_new")]
pub fn new() -> FwNode {
unsafe { from_glib_full(ffi::hinawa_fw_node_new()) }
}
}
impl Default for FwNode {
fn default() -> Self {
Self::new()
}
}
/// Trait containing the part of [`struct@FwNode`] methods.
///
/// # Implementors
///
/// [`FwNode`][struct@crate::FwNode]
pub trait FwNodeExt: IsA<FwNode> + 'static {
/// Create [`glib::Source`][crate::glib::Source] for [`gLib::MainContext`][crate::glib::MainContext]
/// to dispatch events for the node on IEEE 1394 bus.
///
/// # Returns
///
/// TRUE if the overall operation finishes successfully, otherwise FALSE.
///
/// ## `gsrc`
/// A [`glib::Source`][crate::glib::Source].
#[doc(alias = "hinawa_fw_node_create_source")]
fn create_source(&self) -> Result<glib::Source, glib::Error> {
unsafe {
let mut gsrc = std::ptr::null_mut();
let mut error = std::ptr::null_mut();
let is_ok = ffi::hinawa_fw_node_create_source(
self.as_ref().to_glib_none().0,
&mut gsrc,
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(from_glib_full(gsrc))
} else {
Err(from_glib_full(error))
}
}
}
/// Open Linux FireWire character device to operate node in IEEE 1394 bus.
/// ## `path`
/// A path to Linux FireWire character device
/// ## `open_flag`
/// The flag of `open(2)` system call. `O_RDONLY` is fulfilled internally.
///
/// # Returns
///
/// TRUE if the overall operation finishes successfully, otherwise FALSE.
#[doc(alias = "hinawa_fw_node_open")]
fn open(&self, path: &str, open_flag: i32) -> Result<(), glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let is_ok = ffi::hinawa_fw_node_open(
self.as_ref().to_glib_none().0,
path.to_glib_none().0,
open_flag,
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Node ID of node which plays role of bus manager at current generation of bus topology.
#[doc(alias = "bus-manager-node-id")]
fn bus_manager_node_id(&self) -> u32 {
ObjectExt::property(self.as_ref(), "bus-manager-node-id")
}
/// The numeric index for 1394 OHCI hardware used for the communication with the node. The
/// value is stable against bus generation.
#[doc(alias = "card-id")]
fn card_id(&self) -> u32 {
ObjectExt::property(self.as_ref(), "card-id")
}
/// Current generation of bus topology.
fn generation(&self) -> u32 {
ObjectExt::property(self.as_ref(), "generation")
}
/// Node ID of node which plays role of isochronous resource manager at current generation
/// of bus topology.
#[doc(alias = "ir-manager-node-id")]
fn ir_manager_node_id(&self) -> u32 {
ObjectExt::property(self.as_ref(), "ir-manager-node-id")
}
/// Node ID of node which application uses to communicate to node associated to instance of
/// object at current generation of bus topology. In general, it is for 1394 OHCI hardware.
#[doc(alias = "local-node-id")]
fn local_node_id(&self) -> u32 {
ObjectExt::property(self.as_ref(), "local-node-id")
}
/// Node ID of node associated to instance of object at current generation of bus topology.
/// This parameter is effective after the association.
#[doc(alias = "node-id")]
fn node_id(&self) -> u32 {
ObjectExt::property(self.as_ref(), "node-id")
}
/// Node ID of root node in bus topology at current generation of bus topology.
#[doc(alias = "root-node-id")]
fn root_node_id(&self) -> u32 {
ObjectExt::property(self.as_ref(), "root-node-id")
}
/// Emitted when IEEE 1394 bus is updated. Handlers can read current generation in the bus
/// via [`generation`][struct@crate::FwNode#generation] property.
#[doc(alias = "bus-update")]
fn connect_bus_update<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn bus_update_trampoline<P: IsA<FwNode>, F: Fn(&P) + 'static>(
this: *mut ffi::HinawaFwNode,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(FwNode::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"bus-update".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
bus_update_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
/// Emitted when the node is not available anymore in Linux system. It's preferable to call
/// `GObject::Object::unref()` immediately to release file descriptor.
#[doc(alias = "disconnected")]
fn connect_disconnected<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn disconnected_trampoline<P: IsA<FwNode>, F: Fn(&P) + 'static>(
this: *mut ffi::HinawaFwNode,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(FwNode::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"disconnected".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
disconnected_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "bus-manager-node-id")]
fn connect_bus_manager_node_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_bus_manager_node_id_trampoline<
P: IsA<FwNode>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::HinawaFwNode,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(FwNode::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::bus-manager-node-id".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_bus_manager_node_id_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "card-id")]
fn connect_card_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_card_id_trampoline<P: IsA<FwNode>, F: Fn(&P) + 'static>(
this: *mut ffi::HinawaFwNode,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(FwNode::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::card-id".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_card_id_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "generation")]
fn connect_generation_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_generation_trampoline<P: IsA<FwNode>, F: Fn(&P) + 'static>(
this: *mut ffi::HinawaFwNode,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(FwNode::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::generation".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_generation_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "ir-manager-node-id")]
fn connect_ir_manager_node_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_ir_manager_node_id_trampoline<
P: IsA<FwNode>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::HinawaFwNode,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(FwNode::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::ir-manager-node-id".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_ir_manager_node_id_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "local-node-id")]
fn connect_local_node_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_local_node_id_trampoline<
P: IsA<FwNode>,
F: Fn(&P) + 'static,
>(
this: *mut ffi::HinawaFwNode,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(FwNode::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::local-node-id".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_local_node_id_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "node-id")]
fn connect_node_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_node_id_trampoline<P: IsA<FwNode>, F: Fn(&P) + 'static>(
this: *mut ffi::HinawaFwNode,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(FwNode::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::node-id".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_node_id_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "root-node-id")]
fn connect_root_node_id_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_root_node_id_trampoline<P: IsA<FwNode>, F: Fn(&P) + 'static>(
this: *mut ffi::HinawaFwNode,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(FwNode::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::root-node-id".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_root_node_id_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<FwNode>> FwNodeExt for O {}