elefant_tools/storage/
data_format.rs

1/// Describes how data can be copied when using the `COPY` command in postgres.
2#[derive(Debug, Clone)]
3pub enum DataFormat {
4    /// Slightly slower, but works across postgres versions, is human-readable and can be
5    /// outputted in text files.
6    Text,
7
8    /// Faster, but has strict requirements to the postgres version and is not human-readable.
9    PostgresBinary { postgres_version: Option<String> },
10}
11
12impl PartialEq for DataFormat {
13    fn eq(&self, other: &Self) -> bool {
14        match (self, other) {
15            (DataFormat::Text, DataFormat::Text) => true,
16            (
17                DataFormat::PostgresBinary {
18                    postgres_version: left_pg_version,
19                },
20                DataFormat::PostgresBinary {
21                    postgres_version: right_pg_version,
22                },
23            ) => match (left_pg_version, right_pg_version) {
24                (None, _) => true,
25                (_, None) => true,
26                (Some(left), Some(right)) => left == right,
27            },
28            _ => false,
29        }
30    }
31}