file_source_common/
lib.rs

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