diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2022-07-07 13:08:53 +0900 |
---|---|---|
committer | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2022-07-07 13:08:53 +0900 |
commit | f9ec34e2bb4c31665012c2e6e9b226e5adfe9050 (patch) | |
tree | bbaa9032fb56703293f01f4211b4763380ce49ba | |
parent | 60a3f326e72bd277d752629da460ed2b1937f562 (diff) | |
download | hinawa-rs-f9ec34e2bb4c31665012c2e6e9b226e5adfe9050.tar.gz |
hinawa: fulfill documentation from gir file
The gir tool can fulfill documentation from gir file. The documentation
comes from function comment in C library, thus it is necessarily suitable
to rust crate, however it is convenient.
This commit fulfills documentation for the file.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r-- | hinawa/src/auto/enums.rs | 55 | ||||
-rw-r--r-- | hinawa/src/auto/fw_fcp.rs | 35 | ||||
-rw-r--r-- | hinawa/src/auto/fw_node.rs | 40 | ||||
-rw-r--r-- | hinawa/src/auto/fw_req.rs | 16 | ||||
-rw-r--r-- | hinawa/src/auto/fw_resp.rs | 47 | ||||
-rw-r--r-- | hinawa/src/fw_fcp.rs | 25 | ||||
-rw-r--r-- | hinawa/src/fw_node.rs | 9 | ||||
-rw-r--r-- | hinawa/src/fw_req.rs | 50 | ||||
-rw-r--r-- | hinawa/src/fw_resp.rs | 29 | ||||
-rw-r--r-- | hinawa/src/lib.rs | 26 | ||||
-rw-r--r-- | hinawa/src/subclass.rs | 8 | ||||
-rw-r--r-- | hinawa/src/subclass/fw_fcp.rs | 2 | ||||
-rw-r--r-- | hinawa/src/subclass/fw_node.rs | 2 | ||||
-rw-r--r-- | hinawa/src/subclass/fw_req.rs | 2 | ||||
-rw-r--r-- | hinawa/src/subclass/fw_resp.rs | 2 |
15 files changed, 348 insertions, 0 deletions
diff --git a/hinawa/src/auto/enums.rs b/hinawa/src/auto/enums.rs index 0333087..9c954a2 100644 --- a/hinawa/src/auto/enums.rs +++ b/hinawa/src/auto/enums.rs @@ -12,12 +12,15 @@ use glib::StaticType; use glib::Type; use std::fmt; +/// A set of error code for [`glib::Error`][crate::glib::Error] with domain which equals to Hinawa.FwFcpError. #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "HinawaFwFcpError")] pub enum FwFcpError { + /// The transaction is canceled due to response timeout. #[doc(alias = "HINAWA_FW_FCP_ERROR_TIMEOUT")] Timeout, + /// The size of response is larger than expected. #[doc(alias = "HINAWA_FW_FCP_ERROR_LARGE_RESP")] LargeResp, #[doc(hidden)] @@ -112,16 +115,21 @@ impl ToValue for FwFcpError { } } +/// A set of error code for [`glib::Error`][crate::glib::Error] with domain which equals to Hinawa.FwNodeError. #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "HinawaFwNodeError")] pub enum FwNodeError { + /// The node associated to the instance is disconnected. #[doc(alias = "HINAWA_FW_NODE_ERROR_DISCONNECTED")] Disconnected, + /// The instance is already associated to node by opening firewire character device. #[doc(alias = "HINAWA_FW_NODE_ERROR_OPENED")] Opened, + /// The instance is not associated to node by opening firewire character device. #[doc(alias = "HINAWA_FW_NODE_ERROR_NOT_OPENED")] NotOpened, + /// The system call fails. #[doc(alias = "HINAWA_FW_NODE_ERROR_FAILED")] Failed, #[doc(hidden)] @@ -224,30 +232,42 @@ impl ToValue for FwNodeError { } } +/// A representation for rcode of asynchronous transaction on IEEE 1394 bus. #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "HinawaFwRcode")] pub enum FwRcode { + /// For completion. #[doc(alias = "HINAWA_FW_RCODE_COMPLETE")] Complete, + /// For error of conflicting. #[doc(alias = "HINAWA_FW_RCODE_CONFLICT_ERROR")] ConflictError, + /// For error of data. #[doc(alias = "HINAWA_FW_RCODE_DATA_ERROR")] DataError, + /// For error of type. #[doc(alias = "HINAWA_FW_RCODE_TYPE_ERROR")] TypeError, + /// For error of address. #[doc(alias = "HINAWA_FW_RCODE_ADDRESS_ERROR")] AddressError, + /// For error of sending. #[doc(alias = "HINAWA_FW_RCODE_SEND_ERROR")] SendError, + /// For cancellation. #[doc(alias = "HINAWA_FW_RCODE_CANCELLED")] Cancelled, + // For busyness. #[doc(alias = "HINAWA_FW_RCODE_BUSY")] Busy, + /// For generation. #[doc(alias = "HINAWA_FW_RCODE_GENERATION")] Generation, + /// For no acknowledge. #[doc(alias = "HINAWA_FW_RCODE_NO_ACK")] NoAck, + /// For rcode out of specification. #[doc(alias = "HINAWA_FW_RCODE_INVALID")] Invalid, #[doc(hidden)] @@ -351,28 +371,40 @@ impl ToValue for FwRcode { } } +/// A set of error code for [`FwReq`][crate::FwReq]. Each of them has the same value as the +/// corresponding enumeration in [`FwRcode`][crate::FwRcode]. #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "HinawaFwReqError")] pub enum FwReqError { + /// For error of conflicting. #[doc(alias = "HINAWA_FW_REQ_ERROR_CONFLICT_ERROR")] ConflictError, + /// For error of data. #[doc(alias = "HINAWA_FW_REQ_ERROR_DATA_ERROR")] DataError, + /// For error of type. #[doc(alias = "HINAWA_FW_REQ_ERROR_TYPE_ERROR")] TypeError, + /// For error of address. #[doc(alias = "HINAWA_FW_REQ_ERROR_ADDRESS_ERROR")] AddressError, + /// For error of sending. #[doc(alias = "HINAWA_FW_REQ_ERROR_SEND_ERROR")] SendError, + /// For cancellation. #[doc(alias = "HINAWA_FW_REQ_ERROR_CANCELLED")] Cancelled, + /// For busyness. #[doc(alias = "HINAWA_FW_REQ_ERROR_BUSY")] Busy, + /// For generation. #[doc(alias = "HINAWA_FW_REQ_ERROR_GENERATION")] Generation, + /// For no acknowledge. #[doc(alias = "HINAWA_FW_REQ_ERROR_NO_ACK")] NoAck, + /// For rcode out of specification. #[doc(alias = "HINAWA_FW_REQ_ERROR_INVALID")] Invalid, #[doc(hidden)] @@ -499,14 +531,18 @@ impl ToValue for FwReqError { } } +/// A set of error code for [`glib::Error`][crate::glib::Error] with domain which equals to Hinawa.FwRespError. #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "HinawaFwRespError")] pub enum FwRespError { + /// The generic system call error. #[doc(alias = "HINAWA_FW_RESP_ERROR_FAILED")] Failed, + /// The instance is already associated to reserved address range. #[doc(alias = "HINAWA_FW_RESP_ERROR_RESERVED")] Reserved, + /// The address space is used exclusively. #[doc(alias = "HINAWA_FW_RESP_ERROR_ADDR_SPACE_USED")] AddrSpaceUsed, #[doc(hidden)] @@ -605,44 +641,63 @@ impl ToValue for FwRespError { } } +/// A representation for tcode of asynchronous transaction on IEEE 1394 bus. #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "HinawaFwTcode")] pub enum FwTcode { + /// For request to write quadlet. #[doc(alias = "HINAWA_FW_TCODE_WRITE_QUADLET_REQUEST")] WriteQuadletRequest, + /// For request to write block. #[doc(alias = "HINAWA_FW_TCODE_WRITE_BLOCK_REQUEST")] WriteBlockRequest, + /// For response to write. #[doc(alias = "HINAWA_FW_TCODE_WRITE_RESPONSE")] WriteResponse, + /// For response to read quadlet. #[doc(alias = "HINAWA_FW_TCODE_READ_QUADLET_REQUEST")] ReadQuadletRequest, + /// For request to read block. #[doc(alias = "HINAWA_FW_TCODE_READ_BLOCK_REQUEST")] ReadBlockRequest, + /// For response to quadlet read. #[doc(alias = "HINAWA_FW_TCODE_READ_QUADLET_RESPONSE")] ReadQuadletResponse, + /// For response to block read. #[doc(alias = "HINAWA_FW_TCODE_READ_BLOCK_RESPONSE")] ReadBlockResponse, + /// For cycle start. #[doc(alias = "HINAWA_FW_TCODE_CYCLE_START")] CycleStart, + /// For request to lock. #[doc(alias = "HINAWA_FW_TCODE_LOCK_REQUEST")] LockRequest, + /// For stream data. #[doc(alias = "HINAWA_FW_TCODE_STREAM_DATA")] StreamData, + /// For response to lock. #[doc(alias = "HINAWA_FW_TCODE_LOCK_RESPONSE")] LockResponse, + /// For lock request for mask-swap. #[doc(alias = "HINAWA_FW_TCODE_LOCK_MASK_SWAP")] LockMaskSwap, + /// For lock request for compare-swap. #[doc(alias = "HINAWA_FW_TCODE_LOCK_COMPARE_SWAP")] LockCompareSwap, + /// For lock request for fetch-add. #[doc(alias = "HINAWA_FW_TCODE_LOCK_FETCH_ADD")] LockFetchAdd, + /// For lock request for little-add. #[doc(alias = "HINAWA_FW_TCODE_LOCK_LITTLE_ADD")] LockLittleAdd, + /// For lock request for bounded-add. #[doc(alias = "HINAWA_FW_TCODE_LOCK_BOUNDED_ADD")] LockBoundedAdd, + /// For lock request for wrap-add. #[doc(alias = "HINAWA_FW_TCODE_LOCK_WRAP_ADD")] LockWrapAdd, + /// For lock request for vendor-dependent. #[doc(alias = "HINAWA_FW_TCODE_LOCK_VENDOR_DEPENDENT")] LockVendorDependent, #[doc(hidden)] diff --git a/hinawa/src/auto/fw_fcp.rs b/hinawa/src/auto/fw_fcp.rs index a99ceb6..025662c 100644 --- a/hinawa/src/auto/fw_fcp.rs +++ b/hinawa/src/auto/fw_fcp.rs @@ -16,6 +16,19 @@ use std::mem::transmute; use std::ptr; glib::wrapper! { + /// A FCP transaction executor to node in IEEE 1394 bus. + /// + /// A HinawaFwFcp supports Function Control Protocol (FCP) in IEC 61883-1, in which no way is defined + /// to match response against command by the contents of frames. In 'AV/C Digital Interface Command + /// Set General Specification Version 4.2' (Sep 1 2004, 1394TA), a pair of command and response is + /// loosely matched by the contents of frames. + /// + /// Any of transaction frames should be aligned to 8bit (byte). This class is an application of + /// [`FwReq`][crate::FwReq] / [`FwResp`][crate::FwResp]. + /// + /// # Implements + /// + /// [`FwFcpExt`][trait@crate::prelude::FwFcpExt], [`FwRespExt`][trait@crate::prelude::FwRespExt], [`FwFcpExtManual`][trait@crate::prelude::FwFcpExtManual], [`FwRespExtManual`][trait@crate::prelude::FwRespExtManual] #[doc(alias = "HinawaFwFcp")] pub struct FwFcp(Object<ffi::HinawaFwFcp, ffi::HinawaFwFcpClass>) @extends FwResp; @@ -27,6 +40,11 @@ glib::wrapper! { impl FwFcp { pub const NONE: Option<&'static FwFcp> = None; + /// Instantiate [`FwFcp`][crate::FwFcp] object and return the instance. + /// + /// # Returns + /// + /// an instance of [`FwFcp`][crate::FwFcp]. #[doc(alias = "hinawa_fw_fcp_new")] pub fn new() -> FwFcp { unsafe { from_glib_full(ffi::hinawa_fw_fcp_new()) } @@ -39,16 +57,33 @@ impl Default for FwFcp { } } +/// Trait containing the part of [`struct@FwFcp`] methods. +/// +/// # Implementors +/// +/// [`FwFcp`][struct@crate::FwFcp] pub trait FwFcpExt: 'static { + /// Start to listen to FCP responses. + /// ## `node` + /// A [`FwNode`][crate::FwNode]. #[doc(alias = "hinawa_fw_fcp_bind")] fn bind(&self, node: &impl IsA<FwNode>) -> Result<(), glib::Error>; + /// Transfer command frame for FCP. When receiving response frame for FCP, `signal::FwFcp::responded` + /// signal is emitted. + /// ## `cmd` + /// An array with elements for request byte data. The value of this + /// argument should point to the array and immutable. + /// ## `timeout_ms` + /// The timeout to wait for response subaction of transaction for command frame. #[doc(alias = "hinawa_fw_fcp_command")] fn command(&self, cmd: &[u8], timeout_ms: u32) -> Result<(), glib::Error>; + /// Stop to listen to FCP responses. #[doc(alias = "hinawa_fw_fcp_unbind")] fn unbind(&self); + /// Whether this protocol is bound to any instance of HinawaFwNode. #[doc(alias = "is-bound")] fn is_bound(&self) -> bool; diff --git a/hinawa/src/auto/fw_node.rs b/hinawa/src/auto/fw_node.rs index 4ca530c..c139b54 100644 --- a/hinawa/src/auto/fw_node.rs +++ b/hinawa/src/auto/fw_node.rs @@ -14,6 +14,15 @@ use std::mem::transmute; use std::ptr; glib::wrapper! { + /// An event listener for FireWire node + /// + /// A [`FwNode`][crate::FwNode] is an event listener for a specified node on IEEE 1394 bus. This class is an + /// application of Linux FireWire subsystem. All of operations utilize ioctl(2) with subsystem + /// specific request commands. + /// + /// # Implements + /// + /// [`FwNodeExt`][trait@crate::prelude::FwNodeExt], [`FwNodeExtManual`][trait@crate::prelude::FwNodeExtManual] #[doc(alias = "HinawaFwNode")] pub struct FwNode(Object<ffi::HinawaFwNode, ffi::HinawaFwNodeClass>); @@ -25,6 +34,11 @@ glib::wrapper! { 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()) } @@ -37,33 +51,59 @@ impl Default for FwNode { } } +/// Trait containing the part of [`struct@FwNode`] methods. +/// +/// # Implementors +/// +/// [`FwNode`][struct@crate::FwNode] pub trait FwNodeExt: 'static { + /// Create [`glib::Source`][crate::glib::Source] for `GLib::MainContext` to dispatch events for the node on + /// IEEE 1394 bus. + /// + /// # Returns + /// A [`glib::Source`][crate::glib::Source]. #[doc(alias = "hinawa_fw_node_create_source")] fn create_source(&self) -> Result<glib::Source, glib::Error>; + /// Open Linux FireWire character device to operate node on IEEE 1394 bus. + /// ## `path` + /// A path to Linux FireWire character device #[doc(alias = "hinawa_fw_node_open")] fn open(&self, path: &str) -> Result<(), glib::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; + /// Current generation of bus topology. fn generation(&self) -> u32; + /// 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; + /// 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 controller. #[doc(alias = "local-node-id")] fn local_node_id(&self) -> u32; + /// 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; + /// Node ID of root node in bus topology at current generation of the bus topology. #[doc(alias = "root-node-id")] fn root_node_id(&self) -> u32; + /// Emitted when IEEE 1394 bus is updated. Handlers can read current generation in the bus + /// via `property::FwNode::generation` property. #[doc(alias = "bus-update")] fn connect_bus_update<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; + /// Emitted when the node is not available anymore due to removal from IEEE 1394 bus. 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; diff --git a/hinawa/src/auto/fw_req.rs b/hinawa/src/auto/fw_req.rs index 18fad3f..3471c25 100644 --- a/hinawa/src/auto/fw_req.rs +++ b/hinawa/src/auto/fw_req.rs @@ -7,6 +7,17 @@ use glib::translate::*; use std::fmt; glib::wrapper! { + /// A transaction executor to a FireWire unit. + /// + /// A HinawaFwReq supports some types of transactions in IEEE 1212. Mainly for read, write and lock + /// operations. + /// + /// This class is an application of Linux FireWire subsystem. All of operations utilize ioctl(2) + /// with subsystem specific request commands. + /// + /// # Implements + /// + /// [`FwReqExtManual`][trait@crate::prelude::FwReqExtManual] #[doc(alias = "HinawaFwReq")] pub struct FwReq(Object<ffi::HinawaFwReq, ffi::HinawaFwReqClass>); @@ -18,6 +29,11 @@ glib::wrapper! { impl FwReq { pub const NONE: Option<&'static FwReq> = None; + /// Instantiate [`FwReq`][crate::FwReq] object and return the instance. + /// + /// # Returns + /// + /// an instance of [`FwReq`][crate::FwReq]. #[doc(alias = "hinawa_fw_req_new")] pub fn new() -> FwReq { unsafe { from_glib_full(ffi::hinawa_fw_req_new()) } diff --git a/hinawa/src/auto/fw_resp.rs b/hinawa/src/auto/fw_resp.rs index 2c5493a..239c13a 100644 --- a/hinawa/src/auto/fw_resp.rs +++ b/hinawa/src/auto/fw_resp.rs @@ -15,6 +15,16 @@ use std::mem::transmute; use std::ptr; glib::wrapper! { + /// A transaction responder for request initiated by node in IEEE 1394 bus. + /// + /// The [`FwResp`][crate::FwResp] responds transaction initiated by node in IEEE 1394 bus. + /// + /// This class is an application of Linux FireWire subsystem. All of operations utilize ioctl(2) + /// with subsystem specific request commands. + /// + /// # Implements + /// + /// [`FwRespExt`][trait@crate::prelude::FwRespExt], [`FwRespExtManual`][trait@crate::prelude::FwRespExtManual] #[doc(alias = "HinawaFwResp")] pub struct FwResp(Object<ffi::HinawaFwResp, ffi::HinawaFwRespClass>); @@ -26,6 +36,11 @@ glib::wrapper! { 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()) } @@ -38,13 +53,39 @@ impl Default for FwResp { } } +/// Trait containing the part of [`struct@FwResp`] methods. +/// +/// # Implementors +/// +/// [`FwFcp`][struct@crate::FwFcp], [`FwResp`][struct@crate::FwResp] pub trait FwRespExt: 'static { + /// stop to listen to a range of address in local node (e.g. OHCI 1394 controller). #[doc(alias = "hinawa_fw_resp_release")] fn release(&self); + /// Start to listen to a range of address in host controller which connects to the node. The function + /// is a variant of [`reserve_within_region()`][Self::reserve_within_region()] so that the exact range of address should + /// be reserved as given. + /// ## `node` + /// A [`FwNode`][crate::FwNode]. + /// ## `addr` + /// A start address to listen to in host controller. + /// ## `width` + /// The byte width of address to listen to host controller. #[doc(alias = "hinawa_fw_resp_reserve")] fn reserve(&self, node: &impl IsA<FwNode>, addr: u64, width: u32) -> Result<(), glib::Error>; + /// Start to listen to range of address equals to #width in local node (e.g. 1394 OHCI host + /// controller), which is used to communicate to the node given as parameter. The range of address + /// is looked up in region between region_start and region_end. + /// ## `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. #[doc(alias = "hinawa_fw_resp_reserve_within_region")] fn reserve_within_region( &self, @@ -54,14 +95,20 @@ pub trait FwRespExt: 'static { width: u32, ) -> Result<(), glib::Error>; + /// Register byte frame as response. + /// ## `frame` + /// a 8bit array for response frame. #[doc(alias = "hinawa_fw_resp_set_resp_frame")] fn set_resp_frame(&self, frame: &[u8]); + /// Whether a range of address is reserved or not in host controller. #[doc(alias = "is-reserved")] fn is_reserved(&self) -> bool; + /// The start offset of reserved address range. fn offset(&self) -> u64; + /// The width of reserved address range. fn width(&self) -> u32; #[doc(alias = "is-reserved")] diff --git a/hinawa/src/fw_fcp.rs b/hinawa/src/fw_fcp.rs index 04031c2..ef52200 100644 --- a/hinawa/src/fw_fcp.rs +++ b/hinawa/src/fw_fcp.rs @@ -1,7 +1,27 @@ // SPDX-License-Identifier: MIT use crate::*; +/// Trait containing the rest of [`struct@FwFcp`] methods. +/// +/// # Implementors +/// +/// [`FwFcp`][struct@crate::FwFcp] pub trait FwFcpExtManual { + /// Finish the pair of asynchronous transaction for AV/C command and response transactions. The + /// timeout_ms parameter is used to wait for response transaction since the command transaction is + /// initiated, ignoring `property::FwFcp::timeout` property of instance. The timeout is not expanded in + /// the case that AV/C INTERIM status is arrived, thus the caller should expand the timeout in + /// advance for the case. + /// ## `cmd` + /// An array with elements for request byte data. The value of + /// this argument should point to the array and immutable. + /// ## `resp` + /// An array with elements for response byte data. Callers + /// should give it for buffer with enough space against the request since this library + /// performs no reallocation. Due to the reason, the value of this argument should point to + /// the pointer to the array and immutable. The content of array is mutable. + /// ## `timeout_ms` + /// The timeout to wait for response transaction since command transactions finishes. #[doc(alias = "hinawa_fw_fcp_avc_transaction")] fn avc_transaction( &self, @@ -9,6 +29,11 @@ pub trait FwFcpExtManual { resp_frame: &mut [u8], timeout_ms: u32, ) -> Result<usize, glib::Error>; + /// Emitted when the node transfers asynchronous packet as response for FCP and the process + /// successfully read the content of packet. + /// ## `frame` + /// The array with elements for byte + /// data of response for FCP. #[doc(alias = "responded")] fn connect_responded<F>(&self, f: F) -> SignalHandlerId where diff --git a/hinawa/src/fw_node.rs b/hinawa/src/fw_node.rs index 3d2ceb2..8e5927d 100644 --- a/hinawa/src/fw_node.rs +++ b/hinawa/src/fw_node.rs @@ -1,7 +1,16 @@ // SPDX-License-Identifier: MIT use crate::*; +/// Trait containing the rest of [`struct@FwNode`] methods. +/// +/// # Implementors +/// +/// [`FwNode`][struct@crate::FwNode] pub trait FwNodeExtManual { + /// Get cached content of configuration ROM aligned to big-endian. + /// + /// # Returns + /// The content of configuration ROM. #[doc(alias = "hinawa_fw_node_get_config_rom")] #[doc(alias = "get_config_rom")] fn config_rom(&self) -> Result<&[u8], glib::Error>; diff --git a/hinawa/src/fw_req.rs b/hinawa/src/fw_req.rs index 1e362f0..4700197 100644 --- a/hinawa/src/fw_req.rs +++ b/hinawa/src/fw_req.rs @@ -1,7 +1,29 @@ // SPDX-License-Identifier: MIT use crate::*; +/// Trait containing all [`struct@FwReq`] methods. +/// +/// # Implementors +/// +/// [`FwReq`][struct@crate::FwReq] pub trait FwReqExtManual { + /// Execute request subaction of transactions to the given node according to given code. When the + /// response subaction arrives and read the contents, `signal::FwReq::responded` signal handler is called + /// as long as event dispatcher runs. + /// ## `node` + /// A [`FwNode`][crate::FwNode]. + /// ## `tcode` + /// A transaction code of [`FwTcode`][crate::FwTcode]. + /// ## `addr` + /// A destination address of target device + /// ## `length` + /// The range of address in byte unit. + /// ## `frame` + /// An array with elements for byte data. Callers should + /// give it for buffer with enough space against the request since this library performs no + /// reallocation. Due to the reason, the value of this argument should point to the pointer + /// to the array and immutable. The content of array is mutable for read and lock + /// transaction. #[doc(alias = "hinawa_fw_req_transaction_async")] fn transaction_async<P: IsA<FwNode>>( &self, @@ -11,6 +33,26 @@ pub trait FwReqExtManual { length: usize, frame: &mut [u8], ) -> Result<(), glib::Error>; + /// Execute request subaction of transaction to the given node according to given code, then wait + /// for response subaction within the given timeout. The `property::FwReq::timeout` property of + /// instance is ignored. + /// ## `node` + /// A [`FwNode`][crate::FwNode]. + /// ## `tcode` + /// A transaction code of [`FwTcode`][crate::FwTcode]. + /// ## `addr` + /// A destination address of target device + /// ## `length` + /// The range of address in byte unit. + /// ## `frame` + /// An array with elements for byte data. Callers should + /// give it for buffer with enough space against the request since this library performs no + /// reallocation. Due to the reason, the value of this argument should point to the pointer + /// to the array and immutable. The content of array is mutable for read and lock + /// transaction. + /// ## `timeout_ms` + /// The timeout to wait for response subaction of the transaction since request + /// subaction is initiated, in milliseconds. #[doc(alias = "hinawa_fw_req_transaction_sync")] fn transaction_sync<P: IsA<FwNode>>( &self, @@ -21,6 +63,14 @@ pub trait FwReqExtManual { frame: &mut [u8], timeout_ms: u32, ) -> Result<(), glib::Error>; + /// Emitted when the unit transfers asynchronous packet as response subaction for the + /// transaction and the process successfully reads the content of packet from Linux firewire + /// subsystem. + /// ## `rcode` + /// One of [`FwRcode`][crate::FwRcode]. + /// ## `frame` + /// The array with elements for + /// byte data of response subaction for transaction. #[doc(alias = "responded")] fn connect_responded<F>(&self, f: F) -> SignalHandlerId where diff --git a/hinawa/src/fw_resp.rs b/hinawa/src/fw_resp.rs index 0902be0..6e924d0 100644 --- a/hinawa/src/fw_resp.rs +++ b/hinawa/src/fw_resp.rs @@ -1,7 +1,36 @@ // SPDX-License-Identifier: MIT use crate::*; +/// Trait containing the rest of [`struct@FwResp`] methods. +/// +/// # Implementors +/// +/// [`FwResp`][struct@crate::FwResp] pub trait FwRespExtManual { + /// Emitted when any node transfers request subaction to the range of address to which this + /// object listening, the `signal::FwResp::requested` signal handler is called with arrived + /// frame for the subaction. 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. + /// ## `tcode` + /// One of [`FwTcode`][crate::FwTcode] enumerations + /// ## `offset` + /// The address offset at which the transaction arrives. + /// ## `src` + /// The node ID of source for the transaction. + /// ## `dst` + /// The node ID of destination for the transaction. + /// ## `card` + /// The index of card corresponding to 1394 OHCI controller. + /// ## `generation` + /// The generation of bus when the transaction is transferred. + /// ## `frame` + /// The array with elements for byte + /// data. + /// + /// # Returns + /// + /// One of [`FwRcode`][crate::FwRcode] enumerations corresponding to rcodes defined in IEEE 1394 + /// specification. #[doc(alias = "requested")] fn connect_requested2<F>(&self, f: F) -> SignalHandlerId where diff --git a/hinawa/src/lib.rs b/hinawa/src/lib.rs index 6f31167..335070a 100644 --- a/hinawa/src/lib.rs +++ b/hinawa/src/lib.rs @@ -1,4 +1,27 @@ // SPDX-License-Identifier: MIT + +//! Rust bindings for hinawa library +//! +//! Rust bindings and wrappers for [hinawa library](https://github.com/alsa-project/libhinawa) to +//! operate Linux FireWire character device for asynchronous packet and topology generation in +//! IEEE 1394 bus. +//! +//! The hinawa library v2.5.0 is the minimum supported version for underlying library. +//! +//! The crate depends on [glib crate v0.15](https://crates.io/crates/glib) provided by +//! [gtk-rs project](https://gtk-rs.org/) for type/object system, event loop, and dispacher. +//! +//! # License +//! +//! Released under MIT license. +//! +//! # Sample programs +//! +//! Some programs are available under `examples` directory. +//! +//! `read-quadlet` +//! : demonstration to read quadlet data from node in IEEE 1394 bus. + mod auto; mod fw_fcp; mod fw_node; @@ -19,4 +42,7 @@ pub mod subclass; // To access to hinawa-sys crate for FFI. pub use ffi; +// For links in documentation. +use glib; + use glib::{signal::*, translate::*, Cast, IsA, SignalHandlerId}; diff --git a/hinawa/src/subclass.rs b/hinawa/src/subclass.rs index 9c1689b..acb74c0 100644 --- a/hinawa/src/subclass.rs +++ b/hinawa/src/subclass.rs @@ -1,10 +1,18 @@ // SPDX-License-Identifier: MIT +// For subclass of [`FwFcp`][crate::FwFcp]. mod fw_fcp; + +// For subclass of [`FwNode`][crate::FwNode]. mod fw_node; + +// For subclass of [`FwReq`][crate::FwReq]. mod fw_req; + +// For subclass of [`FwResp`][crate::FwResp]. mod fw_resp; +/// For convenience to provide traits and their blanket implementations to write subclass. pub mod prelude { pub use super::{fw_fcp::*, fw_node::*, fw_req::*, fw_resp::*}; } diff --git a/hinawa/src/subclass/fw_fcp.rs b/hinawa/src/subclass/fw_fcp.rs index 68e625a..18842b4 100644 --- a/hinawa/src/subclass/fw_fcp.rs +++ b/hinawa/src/subclass/fw_fcp.rs @@ -2,12 +2,14 @@ use super::*; +/// Trait which should be implemented by subclass of [`FwFcp`][crate::FwFcp]. pub trait FwFcpImpl: ObjectImpl + FwRespImpl { fn responded(&self, fcp: &Self::Type, frame: &[u8]) { self.parent_responded(fcp, frame) } } +/// Trait which is automatically implemented to implementator of [`FwFcpImpl`][self::FwFcpImpl]. pub trait FwFcpImplExt: ObjectSubclass { fn parent_responded(&self, fcp: &Self::Type, frame: &[u8]); } diff --git a/hinawa/src/subclass/fw_node.rs b/hinawa/src/subclass/fw_node.rs index 9aa84c2..aa402b0 100644 --- a/hinawa/src/subclass/fw_node.rs +++ b/hinawa/src/subclass/fw_node.rs @@ -2,6 +2,7 @@ use super::*; +/// Trait which should be implemented by subclass of [`FwNode`][crate::FwNode]. pub trait FwNodeImpl: ObjectImpl { fn bus_update(&self, node: &Self::Type) { self.parent_bus_update(node) @@ -12,6 +13,7 @@ pub trait FwNodeImpl: ObjectImpl { } } +/// Trait which is automatically implemented to implementator of [`FwNodeImpl`][self::FwNodeImpl]. pub trait FwNodeImplExt: ObjectSubclass { fn parent_bus_update(&self, node: &Self::Type); fn parent_disconnected(&self, node: &Self::Type); diff --git a/hinawa/src/subclass/fw_req.rs b/hinawa/src/subclass/fw_req.rs index 63e5d7d..6acf1f6 100644 --- a/hinawa/src/subclass/fw_req.rs +++ b/hinawa/src/subclass/fw_req.rs @@ -2,12 +2,14 @@ use super::*; +/// Trait which should be implemented by subclass of [`FwReq`][crate::FwReq]. pub trait FwReqImpl: ObjectImpl { fn responded(&self, req: &Self::Type, rcode: FwRcode, frame: &[u8]) { self.parent_responded(req, rcode, frame) } } +/// Trait which is automatically implemented to implementator of [`FwReqImpl`][self::FwReqImpl]. pub trait FwReqImplExt: ObjectSubclass { fn parent_responded(&self, req: &Self::Type, rcode: FwRcode, frame: &[u8]); } diff --git a/hinawa/src/subclass/fw_resp.rs b/hinawa/src/subclass/fw_resp.rs index ae5b72b..76f7e82 100644 --- a/hinawa/src/subclass/fw_resp.rs +++ b/hinawa/src/subclass/fw_resp.rs @@ -2,6 +2,7 @@ use super::*; +/// Trait which should be implemented by subclass of [`FwResp`][crate::FwResp]. pub trait FwRespImpl: ObjectImpl { fn requested2( &self, @@ -18,6 +19,7 @@ pub trait FwRespImpl: ObjectImpl { } } +/// Trait which is automatically implemented to implementator of [`FwRespImpl`][self::FwRespImpl]. pub trait FwRespImplExt: ObjectSubclass { fn parent_requested2( &self, |