diff options
Diffstat (limited to 'import/src/lib.rs')
| -rw-r--r-- | import/src/lib.rs | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/import/src/lib.rs b/import/src/lib.rs index 684ef07..98f7216 100644 --- a/import/src/lib.rs +++ b/import/src/lib.rs @@ -3,7 +3,7 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2026 metamuffin <metamuffin.org> */ -#![feature(duration_constants, exit_status_error)] +#![feature(duration_constants, exit_status_error, phantom_variance_markers)] pub mod helpers; pub mod plugins; @@ -18,7 +18,7 @@ use anyhow::{Context, Result, anyhow}; use jellycache::{Cache, HashKey}; use jellycommon::{ internal::{IM_MTIME, IM_PATH}, - jellyobject::{self, ObjectBuffer, Path as TagPath, Tag}, + jellyobject::{self, OBB, Object, Path as TagPath, Tag}, *, }; use jellydb::{Database, Filter, Query, RowNum}; @@ -92,7 +92,7 @@ impl ImportConfig { pub fn update_node( &self, node: RowNum, - mut update: impl FnMut(ObjectBuffer) -> ObjectBuffer, + mut update: impl FnMut(Box<Object>) -> Box<Object>, ) -> Result<()> { self.db.transaction(&mut |txn| { let ob_before = txn.get(node)?.unwrap(); @@ -105,24 +105,24 @@ impl ImportConfig { pub fn update_node_slug( &self, slug: &str, - mut update: impl FnMut(ObjectBuffer) -> ObjectBuffer, + mut update: impl FnMut(Box<Object>) -> Box<Object>, ) -> Result<RowNum> { let mut row = 0; self.db.transaction(&mut |txn| { row = match txn.query_single(node_slug_query(slug))? { Some(r) => r, - None => txn.insert(ObjectBuffer::new(&mut [(NO_SLUG.0, &slug)]))?, + None => txn.insert(OBB::new().with(NO_SLUG, slug).finish())?, }; let node = txn.get(row)?.unwrap(); let node = update(node); - let node = node.as_object().insert(NO_SLUG, slug); + let node = node.insert(NO_SLUG, slug); txn.update(row, node)?; Ok(()) })?; Ok(row) } - pub fn get_node(&self, node: RowNum) -> Result<Option<ObjectBuffer>> { + pub fn get_node(&self, node: RowNum) -> Result<Option<Box<Object>>> { let mut buf = None; self.db.transaction(&mut |txn| { buf = txn.get(node)?; @@ -235,9 +235,9 @@ fn import_traverse( let row = ic.update_node_slug(&slug, |mut node| { if let Some(parent) = parent { - node = node.as_object().extend(NO_PARENT, [parent]); + node = node.extend(NO_PARENT, [parent]); } - node = node.as_object().insert( + node = node.insert( NO_VISIBILITY, if iflags.hidden { VISI_HIDDEN @@ -325,8 +325,8 @@ fn import_file( let slug = get_node_slug(ic, path).unwrap(); let Some(row) = reporting::catch(ic.update_node_slug(&slug, |mut node| { - node = node.as_object().extend(NO_PARENT, [parent]); - node = node.as_object().insert( + node = node.extend(NO_PARENT, [parent]); + node = node.insert( NO_VISIBILITY, if iflags.hidden { VISI_HIDDEN @@ -415,7 +415,7 @@ fn process_node( let mut slug = String::new(); reporting::catch(dba.db.transaction(&mut |txn| { let no = txn.get(node)?.unwrap(); - if let Some(s) = no.as_object().get(NO_SLUG) { + if let Some(s) = no.get(NO_SLUG) { slug = s.to_owned(); } Ok(()) @@ -460,7 +460,7 @@ fn compare_mtime(dba: &ImportConfig, path: &Path) -> Result<bool> { None => was_changed = true, Some(row) => { let meta = txn.get(row)?.unwrap(); - let prev_mtime = meta.as_object().get(IM_MTIME).unwrap_or_default(); + let prev_mtime = meta.get(IM_MTIME).unwrap_or_default(); was_changed = mtime > prev_mtime } } @@ -481,14 +481,11 @@ fn update_mtime(dba: &ImportConfig, path: &Path) -> Result<()> { ..Default::default() })? { Some(row) => row, - None => txn.insert(ObjectBuffer::new(&mut [( - IM_PATH.0, - &path.to_string_lossy().as_bytes(), - )]))?, + None => txn.insert(OBB::new().with(IM_PATH, &path.to_string_lossy()).finish())?, }; let mut ob = txn.get(row)?.unwrap(); - ob = ob.as_object().insert(IM_MTIME, mtime); + ob = ob.insert(IM_MTIME, mtime); txn.update(row, ob)?; Ok(()) |