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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! Conversion traits from various types into PostgreSQL binary format.
//!
//! Trait implementations should properly write bytes into supplied writer
//! according to PostgreSQL binary format.
use io;
/// Trait for `timestamp` type implementations.
///
/// Implementors should write:
/// 1. signed 4 bytes of the following data length, value is required to be `8`
/// 2. signed 8 bytes of the timestamp, expressed as a microseconds amount from `2000-01-01T00:00:00+00:00`.
/// Trait for `timestamp with time zone` type implementations.
///
/// Implementors should write:
/// 1. signed 4 bytes of the following data length, value is required to be `8`
/// 2. signed 8 bytes of the timestamp, expressed as a microseconds amount from `2000-01-01T00:00:00+00:00`.
///
/// Datetime with some timezone specified should be converted into datetime with UTC timezone before.
/// Trait for `date` type implementations.
///
/// Implementors should write:
/// 1. signed 4 bytes of the following data length, value is required to be `4`
/// 2. signed 4 bytes of the date, expressed as a days amount from `2000-01-01`.
/// Trait for `time` type implementations.
///
/// Implementors should write:
/// 1. signed 4 bytes of the following data length, value is required to be `8`
/// 2. signed 8 bytes of the date, expressed as a microseconds amount starting from the `00:00:00`.
/// Trait for `macaddr` type implementations.
///
/// Implementors should write:
/// 1. signed 4 bytes of the following data length, value is required to be `6`
/// 2. 6 bytes of the MAC address
/// Trait for `macaddr8` type implementations.
///
/// Implementors should write:
/// 1. signed 4 bytes of the following data length, value is required to be `6` or `8`
/// 2. 6 or 8 bytes of the MAC address
/// Trait for `uuid` type implementations.
///
/// Implementors should write:
/// 1. signed 4 bytes of the following data length, value is required to be `16`
/// 2. 16 bytes of the UUID