@@ -43,6 +43,7 @@ static MIGRATIONS: LazyLock<Migrations> = LazyLock::new(|| {
4343 ) ,
4444 M :: up( include_str!( "migrations/0005-drop-text-column.sql" ) ) ,
4545 M :: up( include_str!( "migrations/0006-add-nonce-column.sql" ) ) ,
46+ M :: up( include_str!( "migrations/0007-add-title-column.sql" ) ) ,
4647 ] )
4748} ) ;
4849
@@ -86,6 +87,8 @@ pub mod write {
8687 pub uid : Option < i64 > ,
8788 /// Optional password to encrypt the entry
8889 pub password : Option < String > ,
90+ /// Title
91+ pub title : Option < String > ,
8992 }
9093
9194 /// A compressed entry to be inserted.
@@ -163,6 +166,8 @@ pub mod read {
163166 pub uid : Option < i64 > ,
164167 /// Nonce for this entry
165168 pub nonce : Option < Vec < u8 > > ,
169+ /// Title
170+ pub title : Option < String > ,
166171 }
167172
168173 /// Potentially decrypted but still compressed entry
@@ -173,6 +178,8 @@ pub mod read {
173178 must_be_deleted : bool ,
174179 /// User identifier that inserted the entry
175180 uid : Option < i64 > ,
181+ /// Title
182+ title : Option < String > ,
176183 }
177184
178185 /// An entry read from the database.
@@ -183,6 +190,8 @@ pub mod read {
183190 pub must_be_deleted : bool ,
184191 /// User identifier that inserted the entry
185192 pub uid : Option < i64 > ,
193+ /// Title
194+ pub title : Option < String > ,
186195 }
187196
188197 impl DatabaseEntry {
@@ -196,6 +205,7 @@ pub mod read {
196205 data : self . data ,
197206 must_be_deleted : self . must_be_deleted ,
198207 uid : self . uid ,
208+ title : self . title ,
199209 } ) ,
200210 ( Some ( nonce) , Some ( password) ) => {
201211 let encrypted = Encrypted :: new ( self . data , nonce) ;
@@ -204,6 +214,7 @@ pub mod read {
204214 data : decrypted,
205215 must_be_deleted : self . must_be_deleted ,
206216 uid : self . uid ,
217+ title : self . title ,
207218 } )
208219 }
209220 }
@@ -225,6 +236,7 @@ pub mod read {
225236 text,
226237 uid : self . uid ,
227238 must_be_deleted : self . must_be_deleted ,
239+ title : self . title ,
228240 } )
229241 }
230242 }
@@ -255,18 +267,19 @@ impl Database {
255267
256268 spawn_blocking ( move || match entry. expires {
257269 None => conn. lock ( ) . execute (
258- "INSERT INTO entries (id, uid, data, burn_after_reading, nonce) VALUES (?1, ?2, ?3, ?4, ?5)" ,
259- params ! [ id, entry. uid, data, entry. burn_after_reading, nonce] ,
270+ "INSERT INTO entries (id, uid, data, burn_after_reading, nonce, title ) VALUES (?1, ?2, ?3, ?4, ?5, ?6 )" ,
271+ params ! [ id, entry. uid, data, entry. burn_after_reading, nonce, entry . title ] ,
260272 ) ,
261273 Some ( expires) => conn. lock ( ) . execute (
262- "INSERT INTO entries (id, uid, data, burn_after_reading, nonce, expires) VALUES (?1, ?2, ?3, ?4, ?5, datetime('now', ?6))" ,
274+ "INSERT INTO entries (id, uid, data, burn_after_reading, nonce, expires, title ) VALUES (?1, ?2, ?3, ?4, ?5, datetime('now', ?6), ?7 )" ,
263275 params ! [
264276 id,
265277 entry. uid,
266278 data,
267279 entry. burn_after_reading,
268280 nonce,
269- format!( "{expires} seconds" )
281+ format!( "{expires} seconds" ) ,
282+ entry. title,
270283 ] ,
271284 ) ,
272285 } )
@@ -282,7 +295,7 @@ impl Database {
282295
283296 let entry = spawn_blocking ( move || {
284297 conn. lock ( ) . query_row (
285- "SELECT data, burn_after_reading, uid, nonce, expires < datetime('now') FROM entries WHERE id=?1" ,
298+ "SELECT data, burn_after_reading, uid, nonce, expires < datetime('now'), title FROM entries WHERE id=?1" ,
286299 params ! [ id_as_u32] ,
287300 |row| {
288301 Ok ( read:: DatabaseEntry {
@@ -291,6 +304,7 @@ impl Database {
291304 uid : row. get ( 2 ) ?,
292305 nonce : row. get ( 3 ) ?,
293306 expired : row. get :: < _ , Option < bool > > ( 4 ) ?. unwrap_or ( false ) ,
307+ title : row. get :: < _ , Option < String > > ( 5 ) ?,
294308 } )
295309 } ,
296310 )
0 commit comments