Skip to content

Commit 270bf65

Browse files
committed
Share Module: Added Documentation
1 parent a4d04a6 commit 270bf65

File tree

1 file changed

+59
-0
lines changed
  • src/rust/lib_ccxr/src/share

1 file changed

+59
-0
lines changed

src/rust/lib_ccxr/src/share/mod.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,62 @@
1+
//! Module `share` broadcasts subtitle entries over a pub/sub message bus
2+
//! (Nanomsg) and to interoperate with C code via C-compatible FFI bindings.
3+
//!
4+
//! # Overview
5+
//!
6+
//! - CcxSubEntryMessage Represents a single subtitle entry, including timing and text lines.
7+
//! - CcxSubEntries is A collection of `CcxSubEntryMessage` instances generated from a subtitle frame.
8+
//! - CcxShareStatus Enumeration of possible return statuses for share operations.
9+
//! - Ccx_share_ctx Global context holding the Nanomsg socket and stream metadata.
10+
//!
11+
//! ## Features
12+
//!
13+
//! - Initialize and manage a Nanomsg PUB socket for broadcasting messages.
14+
//! - Convert internal `CcSubtitle` frames into one or more [`CcxSubEntryMessage`] instances.
15+
//! - Send packed protobuf messages over the socket, handling lifecycle of messages.
16+
//! - Signal end-of-stream events to subscribers.
17+
//! - Launch external translation processes via system calls.
18+
//!
19+
//! # C-Compatible API
20+
//!
21+
//! All `extern "C"` functions are safe to call from C code and mirror the underlying Rust logic.
22+
//!
23+
//! ## Message Cleanup and Printing
24+
//!| C Function | Rust Binding |
25+
//!|---------------------------------------|--------------------------------------|
26+
//!| [`ccx_sub_entry_msg_cleanup`] | [`ccxr_sub_entry_msg_cleanup`] |
27+
//!| [`ccx_sub_entry_msg_print`] | [`ccxr_sub_entry_msg_print`] |
28+
//!| [`ccx_sub_entries_cleanup`] | [`ccxr_sub_entries_cleanup`] |
29+
//!| [`ccx_sub_entries_print`] | [`ccxr_sub_entries_print`] |
30+
//!
31+
//! ## Service Control
32+
//!| C Function | Rust Binding |
33+
//!|----------------------|-------------------------------|
34+
//!| [`ccx_share_start`] | [`ccxr_share_start`] |
35+
//!| [`ccx_share_stop`] | [`ccxr_share_stop`] |
36+
//!
37+
//! ## Sending Subtitles
38+
//!| C Function | Rust Binding |
39+
//!|-----------------------------|-------------------------------|
40+
//!| [`ccx_share_send`] | [`ccxr_share_send`] |
41+
//!| [`_ccx_share_send`] | [`_ccxr_share_send`] |
42+
//!| [`ccx_share_stream_done`] | [`ccxr_share_stream_done`] |
43+
//!| [`_ccx_share_sub_to_entries`] | [`_ccxr_share_sub_to_entries`]|
44+
//!
45+
//! ## Translator Launch
46+
//!| C Function | Description |
47+
//!|-------------------------------|-------------------------------------------------|
48+
//!| `ccx_share_launch_translator` | Spawn external `cctranslate` process for translation.
49+
//!
50+
//!# Nanomsg Options
51+
//!
52+
//! - Default URL: `tcp://*:3269` (configurable via `ccx_options.sharing_url`).
53+
//! - Linger option set to infinite to ensure messages are delivered before shutdown.
54+
55+
use crate::share::functions::sharing::{
56+
ccxr_sub_entries_cleanup, ccxr_sub_entries_print, ccxr_sub_entry_msg_cleanup,
57+
ccxr_sub_entry_msg_print,
58+
};
59+
160
pub mod ccxr_sub_entry_message;
261
pub mod functions;
362
pub mod tests;

0 commit comments

Comments
 (0)