file_source_common/
lib.rs

1#![deny(warnings)]
2#![deny(clippy::all)]
3
4pub mod buffer;
5pub mod checkpointer;
6mod fingerprinter;
7pub mod internal_events;
8mod metadata_ext;
9
10use vector_config::configurable_component;
11
12pub use self::{
13    checkpointer::{CHECKPOINT_FILE_NAME, Checkpointer, CheckpointsView},
14    fingerprinter::{FileFingerprint, FingerprintStrategy, Fingerprinter},
15    internal_events::FileSourceInternalEvents,
16    metadata_ext::{AsyncFileInfo, PortableFileExt},
17};
18
19pub type FilePosition = u64;
20
21#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
22pub enum ReadFrom {
23    #[default]
24    Beginning,
25    End,
26    Checkpoint(FilePosition),
27}
28
29/// File position to use when reading a new file.
30#[configurable_component]
31#[derive(Copy, Clone, Debug, PartialEq, Eq)]
32#[serde(rename_all = "snake_case")]
33pub enum ReadFromConfig {
34    /// Read from the beginning of the file.
35    Beginning,
36
37    /// Start reading from the current end of the file.
38    End,
39}
40
41impl From<ReadFromConfig> for ReadFrom {
42    fn from(rfc: ReadFromConfig) -> Self {
43        match rfc {
44            ReadFromConfig::Beginning => ReadFrom::Beginning,
45            ReadFromConfig::End => ReadFrom::End,
46        }
47    }
48}