creek_core/write/
mod.rs

1mod data;
2mod encoder;
3mod server;
4mod write_stream;
5
6pub mod error;
7
8pub use data::WriteBlock;
9pub use encoder::{num_files_to_file_name_extension, Encoder, WriteStatus};
10pub use error::{FatalWriteError, WriteError};
11pub use write_stream::WriteDiskStream;
12
13use data::HeapData;
14use server::WriteServer;
15
16pub(crate) enum ServerToClientMsg<E: Encoder> {
17    NewWriteBlock { block: WriteBlock<E::T> },
18    Finished,
19    ReachedMaxSize { num_files: u32 },
20    FatalError(E::FatalError),
21}
22
23pub(crate) enum ClientToServerMsg<E: Encoder> {
24    WriteBlock { block: WriteBlock<E::T> },
25    FinishFile,
26    DiscardFile,
27    DiscardAndRestart,
28}
29
30/// Options for a write stream.
31#[derive(Debug, Clone, Copy)]
32pub struct WriteStreamOptions<E: Encoder> {
33    /// Any additional encoder-specific options.
34    pub additional_opts: E::AdditionalOpts,
35
36    /// The number of write blocks to reserve. This must be sufficiently large to
37    /// ensure there are enough write blocks for the client in the worst case
38    /// write latency scenario.
39    ///
40    /// This should be left alone unless you know what you are doing.
41    pub num_write_blocks: usize,
42
43    /// The number of frames in a write block.
44    ///
45    /// This should be left alone unless you know what you are doing.
46    pub block_size: usize,
47
48    /// The size of the realtime ring buffer that sends data to and from the stream the the
49    /// internal IO server. This must be sufficiently large enough to avoid stalling the channels.
50    ///
51    /// Set this to `None` to automatically find a generous size based on the other write options.
52    /// This should be left as `None` unless you know what you are doing.
53    ///
54    /// The default is `None`.
55    pub server_msg_channel_size: Option<usize>,
56}
57
58impl<E: Encoder> Default for WriteStreamOptions<E> {
59    fn default() -> Self {
60        WriteStreamOptions {
61            additional_opts: Default::default(),
62            num_write_blocks: E::DEFAULT_NUM_WRITE_BLOCKS,
63            block_size: E::DEFAULT_BLOCK_SIZE,
64            server_msg_channel_size: None,
65        }
66    }
67}