pub struct FileFormatVersionNumbers { /* private fields */ }
Expand description
§File format version numbers (2 Bytes)
The file format write version and file format read version at offsets 18 and 19 are intended to allow for enhancements of the file format in future versions of Sqlite. In current versions of Sqlite, both of these values are:
1
for rollback journalling modes; and2
for WAL journalling mode.
If a version of Sqlite coded to the current file format specification encounters a database file where the read version is 1 or 2 but the write version is greater than 2, then the database file must be treated as read-only. If a database file with a read version greater than 2 is encountered, then that database cannot be read or written.
Implementations§
Source§impl FileFormatVersionNumbers
impl FileFormatVersionNumbers
Sourcepub fn write_version(&self) -> &FileFormatWriteVersion
pub fn write_version(&self) -> &FileFormatWriteVersion
Examples found in repository?
examples/sqlite_info.rs (line 55)
36 fn print_sqlite_info(conn: &SqliteConnection) -> AppResult<()> {
37 const LABEL_WIDTH: usize = 21;
38
39 // TODO:
40 let sqlite_header = conn.runtime().header();
41
42 let mut output = "".to_owned();
43
44 output.push_str(&format!(
45 "{label: <w$}{value}\n",
46 w = LABEL_WIDTH,
47 label = "database page size:",
48 value = u32::from(sqlite_header.page_size())
49 ));
50 output.push_str(&format!(
51 "{label: <w$}{value}\n",
52 w = LABEL_WIDTH,
53 label = "write format:",
54 value =
55 u8::from(sqlite_header.file_format_version_numbers().write_version())
56 ));
57 output.push_str(&format!(
58 "{label: <w$}{value}\n",
59 w = LABEL_WIDTH,
60 label = "read format:",
61 value =
62 u8::from(sqlite_header.file_format_version_numbers().read_version())
63 ));
64 output.push_str(&format!(
65 "{label: <w$}{value}\n",
66 w = LABEL_WIDTH,
67 label = "reserved bytes:",
68 value = **sqlite_header.reserved_bytes_per_page()
69 ));
70 output.push_str(&format!(
71 "{label: <w$}{value}\n",
72 w = LABEL_WIDTH,
73 label = "file change counter:",
74 value = **sqlite_header.file_change_counter()
75 ));
76
77 output.push_str(&format!(
78 "{label: <w$}{value}\n",
79 w = LABEL_WIDTH,
80 label = "database page count:",
81 value = **sqlite_header.db_filesize_in_pages()
82 ));
83
84 output.push_str(&format!(
85 "{label: <w$}{value}\n",
86 w = LABEL_WIDTH,
87 label = "freelist page count:",
88 value = **sqlite_header.freelist_pages().total()
89 ));
90
91 output.push_str(&format!(
92 "{label: <w$}{value}\n",
93 w = LABEL_WIDTH,
94 label = "schema cookie:",
95 value = **sqlite_header.schema_cookie()
96 ));
97
98 output.push_str(&format!(
99 "{label: <w$}{value}\n",
100 w = LABEL_WIDTH,
101 label = "schema format:",
102 value = u32::from(sqlite_header.schema_format())
103 ));
104
105 output.push_str(&format!(
106 "{label: <w$}{value}\n",
107 w = LABEL_WIDTH,
108 label = "default cache size:",
109 value = **sqlite_header.suggested_cache_size()
110 ));
111
112 output.push_str(&format!(
113 "{label: <w$}{value}\n",
114 w = LABEL_WIDTH,
115 label = "autovacuum top root:",
116 value = **sqlite_header
117 .incremental_vacuum_settings()
118 .largest_root_btree_page()
119 ));
120
121 output.push_str(&format!(
122 "{label: <w$}{value}\n",
123 w = LABEL_WIDTH,
124 label = "incremental vacuum:",
125 value = u32::from(
126 sqlite_header
127 .incremental_vacuum_settings()
128 .incremental_vacuum_mode()
129 )
130 ));
131
132 output.push_str(&format!(
133 "{label: <w$}{value}\n",
134 w = LABEL_WIDTH,
135 label = "text encoding:",
136 value = sqlite_header.database_text_encoding()
137 ));
138
139 output.push_str(&format!(
140 "{label: <w$}{value}\n",
141 w = LABEL_WIDTH,
142 label = "user version:",
143 value = **sqlite_header.user_version()
144 ));
145
146 output.push_str(&format!(
147 "{label: <w$}{value}\n",
148 w = LABEL_WIDTH,
149 label = "application id:",
150 value = **sqlite_header.application_id()
151 ));
152
153 output.push_str(&format!(
154 "{label: <w$}{value}\n",
155 w = LABEL_WIDTH,
156 label = "software version:",
157 value = **sqlite_header.write_library_version()
158 ));
159
160 println!("{output}");
161 Ok(())
162 }
Sourcepub fn read_version(&self) -> &FileFormatReadVersion
pub fn read_version(&self) -> &FileFormatReadVersion
Examples found in repository?
examples/sqlite_info.rs (line 62)
36 fn print_sqlite_info(conn: &SqliteConnection) -> AppResult<()> {
37 const LABEL_WIDTH: usize = 21;
38
39 // TODO:
40 let sqlite_header = conn.runtime().header();
41
42 let mut output = "".to_owned();
43
44 output.push_str(&format!(
45 "{label: <w$}{value}\n",
46 w = LABEL_WIDTH,
47 label = "database page size:",
48 value = u32::from(sqlite_header.page_size())
49 ));
50 output.push_str(&format!(
51 "{label: <w$}{value}\n",
52 w = LABEL_WIDTH,
53 label = "write format:",
54 value =
55 u8::from(sqlite_header.file_format_version_numbers().write_version())
56 ));
57 output.push_str(&format!(
58 "{label: <w$}{value}\n",
59 w = LABEL_WIDTH,
60 label = "read format:",
61 value =
62 u8::from(sqlite_header.file_format_version_numbers().read_version())
63 ));
64 output.push_str(&format!(
65 "{label: <w$}{value}\n",
66 w = LABEL_WIDTH,
67 label = "reserved bytes:",
68 value = **sqlite_header.reserved_bytes_per_page()
69 ));
70 output.push_str(&format!(
71 "{label: <w$}{value}\n",
72 w = LABEL_WIDTH,
73 label = "file change counter:",
74 value = **sqlite_header.file_change_counter()
75 ));
76
77 output.push_str(&format!(
78 "{label: <w$}{value}\n",
79 w = LABEL_WIDTH,
80 label = "database page count:",
81 value = **sqlite_header.db_filesize_in_pages()
82 ));
83
84 output.push_str(&format!(
85 "{label: <w$}{value}\n",
86 w = LABEL_WIDTH,
87 label = "freelist page count:",
88 value = **sqlite_header.freelist_pages().total()
89 ));
90
91 output.push_str(&format!(
92 "{label: <w$}{value}\n",
93 w = LABEL_WIDTH,
94 label = "schema cookie:",
95 value = **sqlite_header.schema_cookie()
96 ));
97
98 output.push_str(&format!(
99 "{label: <w$}{value}\n",
100 w = LABEL_WIDTH,
101 label = "schema format:",
102 value = u32::from(sqlite_header.schema_format())
103 ));
104
105 output.push_str(&format!(
106 "{label: <w$}{value}\n",
107 w = LABEL_WIDTH,
108 label = "default cache size:",
109 value = **sqlite_header.suggested_cache_size()
110 ));
111
112 output.push_str(&format!(
113 "{label: <w$}{value}\n",
114 w = LABEL_WIDTH,
115 label = "autovacuum top root:",
116 value = **sqlite_header
117 .incremental_vacuum_settings()
118 .largest_root_btree_page()
119 ));
120
121 output.push_str(&format!(
122 "{label: <w$}{value}\n",
123 w = LABEL_WIDTH,
124 label = "incremental vacuum:",
125 value = u32::from(
126 sqlite_header
127 .incremental_vacuum_settings()
128 .incremental_vacuum_mode()
129 )
130 ));
131
132 output.push_str(&format!(
133 "{label: <w$}{value}\n",
134 w = LABEL_WIDTH,
135 label = "text encoding:",
136 value = sqlite_header.database_text_encoding()
137 ));
138
139 output.push_str(&format!(
140 "{label: <w$}{value}\n",
141 w = LABEL_WIDTH,
142 label = "user version:",
143 value = **sqlite_header.user_version()
144 ));
145
146 output.push_str(&format!(
147 "{label: <w$}{value}\n",
148 w = LABEL_WIDTH,
149 label = "application id:",
150 value = **sqlite_header.application_id()
151 ));
152
153 output.push_str(&format!(
154 "{label: <w$}{value}\n",
155 w = LABEL_WIDTH,
156 label = "software version:",
157 value = **sqlite_header.write_library_version()
158 ));
159
160 println!("{output}");
161 Ok(())
162 }
Trait Implementations§
Source§impl Debug for FileFormatVersionNumbers
impl Debug for FileFormatVersionNumbers
Source§impl Default for FileFormatVersionNumbers
impl Default for FileFormatVersionNumbers
Source§fn default() -> FileFormatVersionNumbers
fn default() -> FileFormatVersionNumbers
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for FileFormatVersionNumbers
impl RefUnwindSafe for FileFormatVersionNumbers
impl Send for FileFormatVersionNumbers
impl Sync for FileFormatVersionNumbers
impl Unpin for FileFormatVersionNumbers
impl UnwindSafe for FileFormatVersionNumbers
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more