xitca_postgres/
column.rs

1use core::fmt;
2
3use super::types::Type;
4
5/// Information about a column of a query.
6#[derive(Clone)]
7pub struct Column {
8    name: Box<str>,
9    r#type: Type,
10}
11
12impl Column {
13    pub(crate) fn new(name: &str, r#type: Type) -> Column {
14        Column {
15            name: Box::from(name),
16            r#type,
17        }
18    }
19
20    /// Returns the name of the column.
21    #[inline]
22    pub fn name(&self) -> &str {
23        &self.name
24    }
25
26    /// Returns the type of the column.
27    #[inline]
28    pub fn r#type(&self) -> &Type {
29        &self.r#type
30    }
31}
32
33impl fmt::Debug for Column {
34    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
35        fmt.debug_struct("Column")
36            .field("name", &self.name)
37            .field("type", &self.r#type)
38            .finish()
39    }
40}