xitca_postgres/
column.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use core::fmt;

use super::types::Type;

/// Information about a column of a query.
#[derive(Clone)]
pub struct Column {
    name: Box<str>,
    r#type: Type,
}

impl Column {
    pub(crate) fn new(name: &str, r#type: Type) -> Column {
        Column {
            name: Box::from(name),
            r#type,
        }
    }

    /// Returns the name of the column.
    #[inline]
    pub fn name(&self) -> &str {
        &self.name
    }

    /// Returns the type of the column.
    #[inline]
    pub fn r#type(&self) -> &Type {
        &self.r#type
    }
}

impl fmt::Debug for Column {
    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
        fmt.debug_struct("Column")
            .field("name", &self.name)
            .field("type", &self.r#type)
            .finish()
    }
}