pub struct PostArchiverManager<C = Connection> {
pub caches: Arc<Mutex<ManagerCaches>>,
pub path: PathBuf,
/* private fields */
}utils only.Expand description
Core manager type for post archive operations with SQLite backend
Provides database connection management and access to entity operations
through the Binded type via bind().
§Examples
use post_archiver::manager::PostArchiverManager;
let manager = PostArchiverManager::open_or_create("./data").unwrap();Fields§
§caches: Arc<Mutex<ManagerCaches>>§path: PathBufImplementations§
Source§impl PostArchiverManager
impl PostArchiverManager
Sourcepub fn open<P>(path: P) -> Result<Option<Self>>
pub fn open<P>(path: P) -> Result<Option<Self>>
Opens an existing archive at the specified path
§Returns
Ok(Some(manager))if archive exists and version is compatibleOk(None)if archive doesn’t existErr(_)on database errors
§Examples
use post_archiver::manager::PostArchiverManager;
if let Some(manager) = PostArchiverManager::open("./archive").unwrap() {
println!("Archive opened successfully");
}Sourcepub fn open_uncheck<P>(path: P) -> Result<Option<Self>>
pub fn open_uncheck<P>(path: P) -> Result<Option<Self>>
Opens an existing archive at the specified path without checking version.
§Returns
Ok(Some(manager))if archive existsOk(None)if archive doesn’t existErr(_)on database errors
Sourcepub fn open_or_create<P>(path: P) -> Result<Self>
pub fn open_or_create<P>(path: P) -> Result<Self>
Opens an existing archive or creates a new one if it doesn’t exist
§Examples
use post_archiver::manager::PostArchiverManager;
let manager = PostArchiverManager::open_or_create("./archive").unwrap();Sourcepub fn open_in_memory() -> Result<Self>
pub fn open_in_memory() -> Result<Self>
Creates an in-memory database
§Examples
use post_archiver::manager::PostArchiverManager;
let manager = PostArchiverManager::open_in_memory().unwrap();Sourcepub fn transaction(&mut self) -> Result<PostArchiverManager<Transaction<'_>>>
pub fn transaction(&mut self) -> Result<PostArchiverManager<Transaction<'_>>>
Starts a new transaction
§Examples
use post_archiver::manager::PostArchiverManager;
let mut manager = PostArchiverManager::open_in_memory().unwrap();
let mut tx = manager.transaction().unwrap();
// ... perform operations
tx.commit().unwrap();Source§impl PostArchiverManager<Transaction<'_>>
impl PostArchiverManager<Transaction<'_>>
Source§impl<C> PostArchiverManager<C>where
C: PostArchiverConnection,
impl<C> PostArchiverManager<C>where
C: PostArchiverConnection,
Sourcepub fn conn(&self) -> &Connection
pub fn conn(&self) -> &Connection
Returns a reference to the underlying database connection
Sourcepub fn bind<Id: BindableId>(&self, id: Id) -> Binded<'_, Id, C>
pub fn bind<Id: BindableId>(&self, id: Id) -> Binded<'_, Id, C>
Source§impl<C: PostArchiverConnection> PostArchiverManager<C>
impl<C: PostArchiverConnection> PostArchiverManager<C>
Entry point for the author query builder.
Fetch a single author by primary key. Returns None if not found.
Find an author ID by alias (source + platform).
Fetch all aliases belonging to the given author.
Source§impl<C: PostArchiverConnection> PostArchiverManager<C>
impl<C: PostArchiverConnection> PostArchiverManager<C>
Sourcepub fn collections(&self) -> CollectionQuery<'_, C>
pub fn collections(&self) -> CollectionQuery<'_, C>
Entry point for the collection query builder.
Sourcepub fn get_collection(&self, id: CollectionId) -> Result<Option<Collection>>
pub fn get_collection(&self, id: CollectionId) -> Result<Option<Collection>>
Fetch a single collection by primary key. Returns None if not found.
Sourcepub fn find_collection(&self, name: &str) -> Result<Option<CollectionId>>
pub fn find_collection(&self, name: &str) -> Result<Option<CollectionId>>
Find a collection ID by name (exact match).
Sourcepub fn find_collection_by_source(
&self,
source: &str,
) -> Result<Option<CollectionId>>
pub fn find_collection_by_source( &self, source: &str, ) -> Result<Option<CollectionId>>
Find a collection ID by its source field.
Source§impl<C: PostArchiverConnection> PostArchiverManager<C>
impl<C: PostArchiverConnection> PostArchiverManager<C>
Sourcepub fn get_file_meta(&self, id: FileMetaId) -> Result<Option<FileMeta>>
pub fn get_file_meta(&self, id: FileMetaId) -> Result<Option<FileMeta>>
Fetch a single FileMeta by primary key. Returns None if not found.
Sourcepub fn find_file_meta(
&self,
post: PostId,
filename: &str,
) -> Result<Option<FileMetaId>>
pub fn find_file_meta( &self, post: PostId, filename: &str, ) -> Result<Option<FileMetaId>>
Find a FileMetaId by owning post and filename.
Source§impl<C: PostArchiverConnection> PostArchiverManager<C>
impl<C: PostArchiverConnection> PostArchiverManager<C>
Sourcepub fn platforms(&self) -> PlatformQuery<'_, C>
pub fn platforms(&self) -> PlatformQuery<'_, C>
Entry point for the platform query builder.
Sourcepub fn get_platform(&self, id: PlatformId) -> Result<Option<Platform>>
pub fn get_platform(&self, id: PlatformId) -> Result<Option<Platform>>
Fetch a single platform by primary key. Returns None if not found.
Sourcepub fn find_platform(&self, name: &str) -> Result<Option<PlatformId>>
pub fn find_platform(&self, name: &str) -> Result<Option<PlatformId>>
Find a platform ID by name (exact match, case-sensitive).
Source§impl<C: PostArchiverConnection> PostArchiverManager<C>
impl<C: PostArchiverConnection> PostArchiverManager<C>
Source§impl<C: PostArchiverConnection> PostArchiverManager<C>
impl<C: PostArchiverConnection> PostArchiverManager<C>
Source§impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
Available on crate feature importer only.
importer only.Import an author into the archive.
If the author already exists (by aliases), it updates their name, aliases, and updated date.
§Errors
Returns Error if there was an error accessing the database.
Source§impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
Sourcepub fn import_file_meta(
&self,
post: PostId,
file_meta: &UnsyncFileMeta,
) -> Result<FileMetaId>
Available on crate feature importer only.
pub fn import_file_meta( &self, post: PostId, file_meta: &UnsyncFileMeta, ) -> Result<FileMetaId>
importer only.Create or update a file metadata entry in the archive.
Takes a file metadata object and either creates a new entry or updates an existing one. if a file metadata with the same filename (and post id) already exists, it only updates metadata
§Errors
Returns Error if there was an error accessing the database.
Source§impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
Sourcepub fn import_post(
&self,
post: UnsyncPost,
update_relation: bool,
) -> Result<(PostId, Vec<AuthorId>, Vec<CollectionId>)>
Available on crate feature importer only.
pub fn import_post( &self, post: UnsyncPost, update_relation: bool, ) -> Result<(PostId, Vec<AuthorId>, Vec<CollectionId>)>
importer only.Sourcepub fn import_posts<U>(
&self,
posts: impl IntoIterator<Item = UnsyncPost>,
update_relation: bool,
) -> Result<Vec<PostId>>
Available on crate feature importer only.
pub fn import_posts<U>( &self, posts: impl IntoIterator<Item = UnsyncPost>, update_relation: bool, ) -> Result<Vec<PostId>>
importer only.Source§impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
Sourcepub fn import_collection(
&self,
collection: UnsyncCollection,
) -> Result<CollectionId>
Available on crate feature importer only.
pub fn import_collection( &self, collection: UnsyncCollection, ) -> Result<CollectionId>
importer only.Import a collection into the archive.
If the collection already exists (by source), it updates its name and returns the existing ID.
§Errors
Returns Error if there was an error accessing the database.
Sourcepub fn import_collections(
&self,
collections: impl IntoIterator<Item = UnsyncCollection>,
) -> Result<Vec<CollectionId>>
Available on crate feature importer only.
pub fn import_collections( &self, collections: impl IntoIterator<Item = UnsyncCollection>, ) -> Result<Vec<CollectionId>>
importer only.Import multiple collections into the archive.
This method takes an iterator of UnsyncCollection and imports each one.
§Errors
Returns Error if there was an error accessing the database.
Source§impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
Sourcepub fn import_tag(&self, tag: UnsyncTag) -> Result<TagId>
Available on crate feature importer only.
pub fn import_tag(&self, tag: UnsyncTag) -> Result<TagId>
importer only.Import a tag into the archive.
If the tag already exists, it returns the existing ID.
§Errors
Returns Error if there was an error accessing the database.
Available on crate feature importer only.
importer only.Import multiple tags into the archive.
If a tag already exists, it returns the existing ID.
§Errors
Returns Error if there was an error accessing the database.
Source§impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
Sourcepub fn import_platform(&self, platform: String) -> Result<PlatformId>
Available on crate feature importer only.
pub fn import_platform(&self, platform: String) -> Result<PlatformId>
importer only.Import a platform into the archive.
If the platform already exists, it returns the existing ID.
§Errors
Returns Error if there was an error accessing the database.