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
//! Shared I/O helpers for subtitle file writing.
//!
//! The `open_with_policy` helper centralizes the `WritePolicy` →
//! `tokio::fs::OpenOptions` mapping that every format's `generate()`
//! function needs. Format-specific quirks (e.g. SRT's append-mode
//! blank-line separator) are left to the caller.
use crateSubtitleError;
use crateWritePolicy;
use crateAnyResult;
use Path;
/// Open a file for writing according to the given [`WritePolicy`].
///
/// - `Overwrite` (default): create or truncate.
/// - `RefuseIfExists`: fail with [`SubtitleError::FileExists`] if the
/// path already exists; otherwise create.
/// - `Append`: open for append (create if missing).
///
/// Returns the opened file. The caller is responsible for writing
/// content, flushing, and any format-specific separators.
pub async
/// Convenience: open, write all bytes, flush. For formats with no
/// append-mode separator quirks.
///
/// SRT's `generate` does NOT use this (it needs a blank-line separator
/// in append mode); other formats can.
pub async