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
// 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, FwNode};
use glib::{
prelude::*,
signal::{connect_raw, SignalHandlerId},
translate::*,
};
use std::boxed::Box as Box_;
glib::wrapper! {
/// A transaction responder for request subaction initiated by node in IEEE 1394 bus.
///
/// [`FwResp`][crate::FwResp] responds to request subaction initiated by node in IEEE 1394 bus.
///
/// ## Properties
///
///
/// #### `is-reserved`
/// Whether a range of address is reserved or not.
///
/// Readable
///
///
/// #### `offset`
/// The start offset of reserved address range.
///
/// Readable
///
///
/// #### `width`
/// The width of reserved address range.
///
/// Readable
///
/// ## Signals
///
///
/// #### `requested`
/// Emitted when any node transfers request subaction to local nodes within the address
/// range reserved in Linux system.
///
/// The handler is expected to call [`FwRespExt::set_resp_frame()`][crate::prelude::FwRespExt::set_resp_frame()] with frame and return
/// [`FwRcode`][crate::FwRcode] for response subaction.
///
/// The value of @tstamp is unsigned 16 bit integer including higher 3 bits for three low
/// order bits of second field and the rest 13 bits for cycle field in the format of IEEE
/// 1394 CYCLE_TIMER register.
///
/// If the version of kernel ABI for Linux FireWire subsystem is less than 6, the value of
/// tstamp argument has invalid value (=G_MAXUINT). Furthermore, if the version is less than
/// 4, the src, dst, card, generation arguments have invalid value (=G_MAXUINT).
///
///
///
/// # Implements
///
/// [`FwRespExt`][trait@crate::prelude::FwRespExt], [`FwRespExtManual`][trait@crate::prelude::FwRespExtManual]
#[doc(alias = "HinawaFwResp")]
pub struct FwResp(Object<ffi::HinawaFwResp, ffi::HinawaFwRespClass>);
match fn {
type_ => || ffi::hinawa_fw_resp_get_type(),
}
}
impl FwResp {
pub const NONE: Option<&'static FwResp> = None;
/// Instantiate [`FwResp`][crate::FwResp] object and return the instance.
///
/// # Returns
///
/// a new instance of [`FwResp`][crate::FwResp].
#[doc(alias = "hinawa_fw_resp_new")]
pub fn new() -> FwResp {
unsafe { from_glib_full(ffi::hinawa_fw_resp_new()) }
}
}
impl Default for FwResp {
fn default() -> Self {
Self::new()
}
}
/// Trait containing the part of [`struct@FwResp`] methods.
///
/// # Implementors
///
/// [`FwFcp`][struct@crate::FwFcp], [`FwResp`][struct@crate::FwResp]
pub trait FwRespExt: IsA<FwResp> + 'static {
/// Stop listening to the address range in Linux system for local nodes.
#[doc(alias = "hinawa_fw_resp_release")]
fn release(&self) {
unsafe {
ffi::hinawa_fw_resp_release(self.as_ref().to_glib_none().0);
}
}
/// Allocate an address range within Linux system for local nodes, each of which expresses 1394
/// OHCI hardware. Once successful, [`requested`][struct@crate::FwResp#requested] signal will be emitted whenever any
/// request subactions arrive at the 1394 OHCI hardware within the dedicated range.
///
/// The range is precisely reserved at the address specified by @addr with the size indicated by
/// @width. In essence, this function is a variant of [`reserve_within_region()`][Self::reserve_within_region()] in
/// which the specified address range is reserved as provided.
/// ## `node`
/// A [`FwNode`][crate::FwNode].
/// ## `addr`
/// A start address to listen to in 1394 OHCI hardware.
/// ## `width`
/// The byte width of address to listen to 1394 OHCI hardware.
///
/// # Returns
///
/// TRUE if the overall operation finishes successfully, otherwise FALSE.
#[doc(alias = "hinawa_fw_resp_reserve")]
fn reserve(&self, node: &impl IsA<FwNode>, addr: u64, width: u32) -> Result<(), glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let is_ok = ffi::hinawa_fw_resp_reserve(
self.as_ref().to_glib_none().0,
node.as_ref().to_glib_none().0,
addr,
width,
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Allocate an address range within Linux system for local nodes, each of which expresses 1394
/// OHCI hardware. Once successful, [`requested`][struct@crate::FwResp#requested] signal will be emitted whenever any
/// request subactions arrive at the 1394 OHCI hardware within the dedicated range.
///
/// The range is reserved between the values specified by @region_start and @region_end with the size
/// indicated by @width. The starting offset may vary every time.
/// ## `node`
/// A [`FwNode`][crate::FwNode].
/// ## `region_start`
/// Start offset of address region in which range of address is looked up.
/// ## `region_end`
/// End offset of address region in which range of address is looked up.
/// ## `width`
/// The width for range of address to be looked up.
///
/// # Returns
///
/// TRUE if the overall operation finishes successfully, otherwise FALSE.
#[doc(alias = "hinawa_fw_resp_reserve_within_region")]
fn reserve_within_region(
&self,
node: &impl IsA<FwNode>,
region_start: u64,
region_end: u64,
width: u32,
) -> Result<(), glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let is_ok = ffi::hinawa_fw_resp_reserve_within_region(
self.as_ref().to_glib_none().0,
node.as_ref().to_glib_none().0,
region_start,
region_end,
width,
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Register byte frame for the response subaction of transaction.
/// ## `frame`
/// a 8 bit array for response frame.
#[doc(alias = "hinawa_fw_resp_set_resp_frame")]
fn set_resp_frame(&self, frame: &[u8]) {
let length = frame.len() as _;
unsafe {
ffi::hinawa_fw_resp_set_resp_frame(
self.as_ref().to_glib_none().0,
frame.to_glib_none().0,
length,
);
}
}
/// Whether a range of address is reserved or not.
#[doc(alias = "is-reserved")]
fn is_reserved(&self) -> bool {
ObjectExt::property(self.as_ref(), "is-reserved")
}
/// The start offset of reserved address range.
fn offset(&self) -> u64 {
ObjectExt::property(self.as_ref(), "offset")
}
/// The width of reserved address range.
fn width(&self) -> u32 {
ObjectExt::property(self.as_ref(), "width")
}
#[doc(alias = "is-reserved")]
fn connect_is_reserved_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_is_reserved_trampoline<P: IsA<FwResp>, F: Fn(&P) + 'static>(
this: *mut ffi::HinawaFwResp,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(FwResp::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::is-reserved".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_is_reserved_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "offset")]
fn connect_offset_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_offset_trampoline<P: IsA<FwResp>, F: Fn(&P) + 'static>(
this: *mut ffi::HinawaFwResp,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(FwResp::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::offset".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_offset_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
#[doc(alias = "width")]
fn connect_width_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_width_trampoline<P: IsA<FwResp>, F: Fn(&P) + 'static>(
this: *mut ffi::HinawaFwResp,
_param_spec: glib::ffi::gpointer,
f: glib::ffi::gpointer,
) {
let f: &F = &*(f as *const F);
f(FwResp::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"notify::width".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
notify_width_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f),
)
}
}
}
impl<O: IsA<FwResp>> FwRespExt for O {}