Skip to main content

tokio_process_tools/process_handle/output_collection/
options.rs

1use crate::{LineCollectionOptions, RawCollectionOptions};
2use std::time::Duration;
3
4/// Default grace period for output consumers to observe EOF after process termination.
5pub const DEFAULT_OUTPUT_EOF_TIMEOUT: Duration = Duration::from_secs(3);
6
7/// Options for line output collection from stdout and stderr.
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub struct LineOutputOptions {
10    /// Collection options used for stdout.
11    pub stdout_collection_options: LineCollectionOptions,
12
13    /// Collection options used for stderr.
14    pub stderr_collection_options: LineCollectionOptions,
15}
16
17impl LineOutputOptions {
18    /// Use the same [`LineCollectionOptions`] for both stdout and stderr.
19    #[must_use]
20    pub const fn symmetric(options: LineCollectionOptions) -> Self {
21        Self {
22            stdout_collection_options: options,
23            stderr_collection_options: options,
24        }
25    }
26}
27
28/// Options for raw byte output collection from stdout and stderr.
29#[derive(Debug, Clone, Copy, PartialEq, Eq)]
30pub struct RawOutputOptions {
31    /// Collection options used for stdout.
32    pub stdout_collection_options: RawCollectionOptions,
33
34    /// Collection options used for stderr.
35    pub stderr_collection_options: RawCollectionOptions,
36}
37
38impl RawOutputOptions {
39    /// Use the same [`RawCollectionOptions`] for both stdout and stderr.
40    #[must_use]
41    pub const fn symmetric(options: RawCollectionOptions) -> Self {
42        Self {
43            stdout_collection_options: options,
44            stderr_collection_options: options,
45        }
46    }
47}