Something went wrong. Try again.
fork of hydrant
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778//! backlinks index hooks for record ops. no-ops when the feature is off so//! `apply_commit`/`delete_repo` stay unconditional.
use fjall::OwnedWriteBatch;use jacquard_common::types::did::Did;use miette::Result;
use crate::db::Db;
#[cfg(feature = "backlinks")]pub(crate) fn index_record( batch: &mut OwnedWriteBatch, db: &Db, did: &Did, collection: &str, rkey: &str, bytes: &[u8],) -> Result<()> { if let Ok(value) = serde_ipld_dagcbor::from_slice::<jacquard_common::Data>(bytes) { crate::backlinks::store::index_record( batch, &db.backlinks, did.as_str(), collection, rkey, &value, )?; } Ok(())}
#[cfg(not(feature = "backlinks"))]#[inline(always)]pub(crate) fn index_record( _batch: &mut OwnedWriteBatch, _db: &Db, _did: &Did, _collection: &str, _rkey: &str, _bytes: &[u8],) -> Result<()> { Ok(())}
#[cfg(feature = "backlinks")]pub(crate) fn delete_record( batch: &mut OwnedWriteBatch, db: &Db, did: &Did, collection: &str, rkey: &str,) -> Result<()> { crate::backlinks::store::delete_record(batch, &db.backlinks, did.as_str(), collection, rkey)}
#[cfg(not(feature = "backlinks"))]#[inline(always)]pub(crate) fn delete_record( _batch: &mut OwnedWriteBatch, _db: &Db, _did: &Did, _collection: &str, _rkey: &str,) -> Result<()> { Ok(())}
#[cfg(feature = "backlinks")]pub(crate) fn delete_repo(batch: &mut OwnedWriteBatch, db: &Db, did: &Did) -> Result<()> { crate::backlinks::store::delete_repo(batch, &db.backlinks, did)}
#[cfg(not(feature = "backlinks"))]#[inline(always)]pub(crate) fn delete_repo(_batch: &mut OwnedWriteBatch, _db: &Db, _did: &Did) -> Result<()> { Ok(())}