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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use serde::Deserialize;

use crate::options::ProtocolVersion;

/// Struct representing database information returned after establishing a connection.
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SessionInfo {
    protocol_version: ProtocolVersion,
    session_id: u64,
    release_version: String,
    database_name: String,
    product_name: String,
    max_data_message_size: u64,
    max_identifier_length: u64,
    max_varchar_length: u64,
    identifier_quote_string: String,
    time_zone: String,
    time_zone_behavior: String,
}

impl SessionInfo {
    pub fn protocol_version(&self) -> ProtocolVersion {
        self.protocol_version
    }

    pub fn session_id(&self) -> u64 {
        self.session_id
    }

    pub fn release_version(&self) -> &str {
        &self.release_version
    }

    pub fn database_name(&self) -> &str {
        &self.database_name
    }

    pub fn product_name(&self) -> &str {
        &self.product_name
    }

    pub fn max_data_message_size(&self) -> u64 {
        self.max_data_message_size
    }

    pub fn max_identifier_length(&self) -> u64 {
        self.max_identifier_length
    }

    pub fn max_varchar_length(&self) -> u64 {
        self.max_varchar_length
    }

    pub fn identifier_quote_string(&self) -> &str {
        &self.identifier_quote_string
    }

    pub fn timezone(&self) -> &str {
        &self.time_zone
    }

    pub fn time_zone_behavior(&self) -> &str {
        &self.time_zone_behavior
    }
}