pub struct PostArchiverManager<T = Connection> {
pub path: PathBuf,
/* private fields */
}utils only.Expand description
Core manager type for post archive operations with SQLite backend
§Examples
use post_archiver::manager::PostArchiverManager;
let manager = PostArchiverManager::open_or_create("./data").unwrap();Fields§
§path: PathBufImplementations§
Source§impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
Retrieve all authors in the archive.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Find an author by their aliases.
Checks if any of the provided aliases match an existing author in the archive.
§Errors
Returns rusqlite::Error if there was an error querying the database.
§Examples
let platform = todo!("Define your platform ID here");
let author = manager.find_author(&[("octocat", platform)])?;
match author {
Some(id) => println!("Found author with ID: {}", id),
None => println!("No author found for the given aliases"),
}Retrieve an author by their ID.
Fetches all information about an author including their name, links, and metadata.
§Errors
Returns rusqlite::Error if:
- The author ID does not exist
- There was an error accessing the database
Source§impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
Add a new author to the archive.
Inserts a new author with the given name and optional updated timestamp. It does not check for duplicates, so ensure the author does not already exist.
§Parameters
- updated: Optional timestamp for when the author was last updated. Defaults to the current time if not provided.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Remove an author from the archive.
This operation will also remove all associated aliases. And Author-Post relationships will be removed as well.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Add or update aliases for an author.
Inserts multiple aliases for the specified author. If alias.source and alias.platform already exist for the author, it will be replaced.
§Parameters
- aliases[..]: (Source, Platform, Link)
§Errors
Returns rusqlite::Error if there was an error accessing the database.
§Examples
let aliases = vec![
("octocat".to_string(), PlatformId(1), Some("https://example.com/octocat".to_string())),
("octocat2".to_string(), PlatformId(2), None),
];
manager.add_author_aliases(author_id, aliases)Set an name of author.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Set a thumb of author.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Set the author’s thumb to the latest post’s thumb that has a non-null thumb.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Set the updated timestamp of an author.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Source§impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
Retrieve all aliases associated with an author.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Retrieve all posts associated with an author.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Retrieve all authors associated with a post.
§Errors
Returns rusqlite::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 list_collections(&self) -> Result<Vec<Collection>, Error>
pub fn list_collections(&self) -> Result<Vec<Collection>, Error>
Retrieve all collections in the archive.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn find_collection(
&self,
source: &str,
) -> Result<Option<CollectionId>, Error>
pub fn find_collection( &self, source: &str, ) -> Result<Option<CollectionId>, Error>
Find a collection by its source.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn get_collection(
&self,
id: &CollectionId,
) -> Result<Option<Collection>, Error>
pub fn get_collection( &self, id: &CollectionId, ) -> Result<Option<Collection>, Error>
Retrieve a collection by their ID.
Fetches all information about a collection including its name, source, and thumb.
§Errors
Returns rusqlite::Error if:
- The collection ID does not exist
- There was an error accessing the database
Source§impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
Sourcepub fn add_collection(
&self,
name: String,
source: Option<String>,
thumb: Option<FileMetaId>,
) -> Result<CollectionId, Error>
pub fn add_collection( &self, name: String, source: Option<String>, thumb: Option<FileMetaId>, ) -> Result<CollectionId, Error>
Add a new collection to the archive.
inserts a new collection with the given name, an optional source, and an optional thumb.
§Errors
Returns rusqlite::Error if:
- If the source is already in use by another collection
- There was an error accessing the database
Sourcepub fn remove_collection(&self, id: CollectionId) -> Result<(), Error>
pub fn remove_collection(&self, id: CollectionId) -> Result<(), Error>
Remove a collection from the archive.
The operation will also remove Author-Post relationships associated with the collection.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn set_collection_name(
&self,
id: CollectionId,
name: String,
) -> Result<(), Error>
pub fn set_collection_name( &self, id: CollectionId, name: String, ) -> Result<(), Error>
Set an name of a collection.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn set_collection_source(
&self,
id: CollectionId,
source: Option<String>,
) -> Result<(), Error>
pub fn set_collection_source( &self, id: CollectionId, source: Option<String>, ) -> Result<(), Error>
Set the source of a collection.
§Errors
Returns rusqlite::Error if:
- The source is already in use by another collection.
- There was an error accessing the database.
Sourcepub fn set_collection_thumb(
&self,
id: CollectionId,
thumb: Option<String>,
) -> Result<(), Error>
pub fn set_collection_thumb( &self, id: CollectionId, thumb: Option<String>, ) -> Result<(), Error>
Set the thumb of a collection.
§Errors
Returns rusqlite::Error if:
- The thumb ID does not exist.
- There was an error accessing the database.
Sourcepub fn set_collection_thumb_by_latest(
&self,
id: CollectionId,
) -> Result<(), Error>
pub fn set_collection_thumb_by_latest( &self, id: CollectionId, ) -> Result<(), Error>
Set the collection’s thumb to the latest post’s thumb that has a non-null thumb.
§Errors
Returns rusqlite::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 list_post_collections(
&self,
post: &PostId,
) -> Result<Vec<Collection>, Error>
pub fn list_post_collections( &self, post: &PostId, ) -> Result<Vec<Collection>, Error>
Retrieve all collections associated with a post.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn list_collection_posts(
&self,
collection: &CollectionId,
) -> Result<Vec<Post>, Error>
pub fn list_collection_posts( &self, collection: &CollectionId, ) -> Result<Vec<Post>, Error>
Retrieve all posts associated with a collection.
§Errors
Returns rusqlite::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 find_file_meta(
&self,
post: PostId,
filename: &str,
) -> Result<Option<FileMetaId>, Error>
pub fn find_file_meta( &self, post: PostId, filename: &str, ) -> Result<Option<FileMetaId>, Error>
Find a file’s metadata by its post ID and filename.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn get_file_meta(&self, id: &FileMetaId) -> Result<FileMeta, Error>
pub fn get_file_meta(&self, id: &FileMetaId) -> Result<FileMeta, Error>
Retrieve a file’s metadata by its ID.
Fetches all information about the file including its post ID, filename, MIME type, and extra metadata.
§Errors
Returns rusqlite::Error if:
- The file ID does not exist
- There was an error accessing the database
Source§impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
Sourcepub fn add_file_meta(
&self,
post: PostId,
filename: String,
mime: String,
extra: HashMap<String, Value>,
) -> Result<FileMetaId, Error>
pub fn add_file_meta( &self, post: PostId, filename: String, mime: String, extra: HashMap<String, Value>, ) -> Result<FileMetaId, Error>
Add a new file metadata to the archive.
Inserts a new file metadata with the given post ID, filename, MIME type, and extra metadata. It will check if a file with the same post and filename already exists.
§Errors
Returns rusqlite::Error if:
- The post ID does not exist
- Duplicate filename for the same post
- There was an error accessing the database
Sourcepub fn remove_file_meta(&self, id: FileMetaId) -> Result<(), Error>
pub fn remove_file_meta(&self, id: FileMetaId) -> Result<(), Error>
Remove a file metadata from the archive.
This operation will also remove all associated thumb references. But it will not delete post.content related to this file.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn set_file_meta_mime(
&self,
id: FileMetaId,
mime: String,
) -> Result<(), Error>
pub fn set_file_meta_mime( &self, id: FileMetaId, mime: String, ) -> Result<(), Error>
Set the filename of a file metadata.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn set_file_meta_extra(
&self,
id: FileMetaId,
extra: HashMap<String, Value>,
) -> Result<(), Error>
pub fn set_file_meta_extra( &self, id: FileMetaId, extra: HashMap<String, Value>, ) -> Result<(), Error>
Set the extra metadata of a file metadata.
§Errors
Returns rusqlite::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 list_platforms(&self) -> Result<Vec<Platform>, Error>
pub fn list_platforms(&self) -> Result<Vec<Platform>, Error>
Retrieve all platforms in the archive.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn find_platform(&self, name: &str) -> Result<Option<PlatformId>, Error>
pub fn find_platform(&self, name: &str) -> Result<Option<PlatformId>, Error>
Find a platform by its name.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn get_platform(&self, id: &PlatformId) -> Result<Platform, Error>
pub fn get_platform(&self, id: &PlatformId) -> Result<Platform, Error>
Retrieve a platform by its ID.
§Errors
Returns rusqlite::Error if:
- The platform ID does not exist
- There was an error accessing the database
Source§impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
Sourcepub fn add_platform(&self, platform: String) -> Result<PlatformId, Error>
pub fn add_platform(&self, platform: String) -> Result<PlatformId, Error>
Add a new platform to the archive.
§Errors
Returns rusqlite::Error if:
- The platform already exists
- There was an error accessing the database
Sourcepub fn remove_platform(&self, id: &PlatformId) -> Result<(), Error>
pub fn remove_platform(&self, id: &PlatformId) -> Result<(), Error>
Remove a platform from the archive.
This operation will also set the platform to UNKNOWN for all author aliases and posts with the platform. But it will delete tags associated with the platform.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn set_platform_name(
&self,
id: &PlatformId,
name: String,
) -> Result<(), Error>
pub fn set_platform_name( &self, id: &PlatformId, name: String, ) -> Result<(), Error>
Set the name of a platform.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Source§impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
List all tags associated with a platform.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn list_platform_posts(
&self,
platform: &Option<PlatformId>,
) -> Result<Vec<Post>, Error>
pub fn list_platform_posts( &self, platform: &Option<PlatformId>, ) -> Result<Vec<Post>, Error>
List all posts associated with a platform.
§Errors
Returns rusqlite::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 list_posts(&self) -> Result<Vec<Post>, Error>
pub fn list_posts(&self) -> Result<Vec<Post>, Error>
Retrieve all posts in the archive.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn find_post(&self, source: &str) -> Result<Option<PostId>, Error>
pub fn find_post(&self, source: &str) -> Result<Option<PostId>, Error>
Find a post by its source.
§errors
Returns rusqlite::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 add_post(
&self,
title: String,
source: Option<String>,
platform: Option<PlatformId>,
published: Option<DateTime<Utc>>,
updated: Option<DateTime<Utc>>,
) -> Result<PostId, Error>
pub fn add_post( &self, title: String, source: Option<String>, platform: Option<PlatformId>, published: Option<DateTime<Utc>>, updated: Option<DateTime<Utc>>, ) -> Result<PostId, Error>
Add a new post to the archive.
§Errors
Returns rusqlite::Error if:
- The post already exists with the same source
- There was an error accessing the database
Sourcepub fn remove_post(&self, post: PostId) -> Result<(), Error>
pub fn remove_post(&self, post: PostId) -> Result<(), Error>
Remove a post from the archive.
This operation will also remove all file metadata, author associations, tag associations, and collection associations for the post.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Associate one or more authors with a post.
Creates author associations between a post and the provided author IDs. Duplicate associations are silently ignored.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Remove one or more authors from a post.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Associate one or more tags with a post.
Creates tag associations between a post and the provided tag IDs. Duplicate associations are silently ignored.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Remove one or more tags from a post.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn add_post_collections(
&self,
post: PostId,
collections: &[CollectionId],
) -> Result<(), Error>
pub fn add_post_collections( &self, post: PostId, collections: &[CollectionId], ) -> Result<(), Error>
Associate one or more tags with a post.
Creates tag associations between a post and the provided tag IDs. Duplicate associations are silently ignored.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn remove_post_collections(
&self,
post: PostId,
collections: &[CollectionId],
) -> Result<(), Error>
pub fn remove_post_collections( &self, post: PostId, collections: &[CollectionId], ) -> Result<(), Error>
Remove one or more collections from a post.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn set_post_source(
&self,
post: PostId,
source: Option<String>,
) -> Result<(), Error>
pub fn set_post_source( &self, post: PostId, source: Option<String>, ) -> Result<(), Error>
Set a post’s source URL.
Sets the source identifier for a post, or removes it by passing None.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn set_post_platform(
&self,
post: PostId,
platform: Option<PlatformId>,
) -> Result<(), Error>
pub fn set_post_platform( &self, post: PostId, platform: Option<PlatformId>, ) -> Result<(), Error>
Set a post’s platform.
Associates a file metadata ID as the post’s thumbnail, or removes it by passing None.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn set_post_title(&self, post: PostId, title: String) -> Result<(), Error>
pub fn set_post_title(&self, post: PostId, title: String) -> Result<(), Error>
Set a post’s title.
Sets a new title for the specified post.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn set_post_thumb(
&self,
post: PostId,
thumb: Option<FileMetaId>,
) -> Result<(), Error>
pub fn set_post_thumb( &self, post: PostId, thumb: Option<FileMetaId>, ) -> Result<(), Error>
Set a post’s thumbnail.
Associates a file metadata ID as the post’s thumbnail, or removes it by passing None.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn set_post_content(
&self,
post: PostId,
content: Vec<Content>,
) -> Result<(), Error>
pub fn set_post_content( &self, post: PostId, content: Vec<Content>, ) -> Result<(), Error>
Set a post’s content.
Replaces the entire content of a post with new text and file entries.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn set_post_comments(
&self,
post: PostId,
comments: Vec<Comment>,
) -> Result<(), Error>
pub fn set_post_comments( &self, post: PostId, comments: Vec<Comment>, ) -> Result<(), Error>
Set a post’s comments.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn set_post_published(
&self,
post: PostId,
published: DateTime<Utc>,
) -> Result<(), Error>
pub fn set_post_published( &self, post: PostId, published: DateTime<Utc>, ) -> Result<(), Error>
Set a post’s published timestamp.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Source§impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
Retrieve all tags in the archive.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn find_tag<U: FindTag>(&self, tag: &U) -> Result<Option<TagId>, Error>
pub fn find_tag<U: FindTag>(&self, tag: &U) -> Result<Option<TagId>, Error>
Find a tag by its name and platform.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
§Examples
fn example(manager: &PostArchiverManager) -> Result<(), rusqlite::Error> {
let first_tag = manager.find_tag(&"tag1")?;
let second_tag = manager.find_tag(&("tag2", PlatformId(2)))?;
let third_tag = manager.find_tag(&("tag3", Some(PlatformId(3))))?;
Ok(())
}Source§impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
Sourcepub fn add_tag(
&self,
name: String,
platform: Option<PlatformId>,
) -> Result<TagId, Error>
pub fn add_tag( &self, name: String, platform: Option<PlatformId>, ) -> Result<TagId, Error>
Add a new tag to the archive.
§Errors
Returns rusqlite::Error if:
- The tag already exists
- There was an error accessing the database
Sourcepub fn set_tag_name(&self, tag: &TagId, name: String) -> Result<(), Error>
pub fn set_tag_name(&self, tag: &TagId, name: String) -> Result<(), Error>
Set the name of a tag.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Sourcepub fn set_tag_platform(
&self,
tag: &TagId,
platform: Option<PlatformId>,
) -> Result<(), Error>
pub fn set_tag_platform( &self, tag: &TagId, platform: Option<PlatformId>, ) -> Result<(), Error>
Set the platform of a tag.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Source§impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
List all tags associated with a post.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
Source§impl PostArchiverManager
impl PostArchiverManager
Sourcepub fn open<P>(path: P) -> Result<Option<Self>, Error>
pub fn open<P>(path: P) -> Result<Option<Self>, Error>
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>, Error>
pub fn open_uncheck<P>(path: P) -> Result<Option<Self>, Error>
Opens an existing archive at the specified path Does not check the version of the archive.
§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_uncheck("./archive").unwrap() {
println!("Archive opened successfully");
}Sourcepub fn open_or_create<P>(path: P) -> Result<Self, Error>
pub fn open_or_create<P>(path: P) -> Result<Self, Error>
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, Error>
pub fn open_in_memory() -> Result<Self, Error>
Creates an in-memory database
it will generate a temporary path for the archive files
§Examples
use post_archiver::manager::PostArchiverManager;
let manager = PostArchiverManager::open_in_memory().unwrap();Sourcepub fn transaction(
&mut self,
) -> Result<PostArchiverManager<Transaction<'_>>, Error>
pub fn transaction( &mut self, ) -> Result<PostArchiverManager<Transaction<'_>>, Error>
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<T> PostArchiverManager<T>where
T: PostArchiverConnection,
impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
pub fn conn(&self) -> &Connection
Sourcepub fn get_feature(&self, name: &str) -> Result<i64, Error>
pub fn get_feature(&self, name: &str) -> Result<i64, Error>
Returns this archive’s feature value by name.
§Errors
Returns rusqlite::Error if there was an error accessing the database or if the feature does not exist.
§Examples
use post_archiver::manager::PostArchiverManager;
let manager = PostArchiverManager::open_in_memory().unwrap();
let feature_value = manager.get_feature("example_feature").unwrap();
println!("Feature value: {}", feature_value);Sourcepub fn get_feature_with_extra(
&self,
name: &str,
) -> Result<(i64, HashMap<String, Value>), Error>
pub fn get_feature_with_extra( &self, name: &str, ) -> Result<(i64, HashMap<String, Value>), Error>
Returns this archive’s feature value and extra data by name.
§Errors
Returns rusqlite::Error if there was an error accessing the database or if the feature does not exist.
§Examples
use post_archiver::manager::PostArchiverManager;
let manager = PostArchiverManager::open_in_memory().unwrap();
let (value, extra) = manager.get_feature_with_extra("example_feature").unwrap();
println!("Feature value: {}, Extra: {:?}", value, extra);Sourcepub fn set_feature(&self, name: &str, value: i64)
pub fn set_feature(&self, name: &str, value: i64)
Set feature value by name.
if it exists, its value will be updated.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
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 rusqlite::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<U>(
&self,
post: PostId,
file_meta: &UnsyncFileMeta<U>,
) -> Result<FileMetaId, Error>
Available on crate feature importer only.
pub fn import_file_meta<U>( &self, post: PostId, file_meta: &UnsyncFileMeta<U>, ) -> Result<FileMetaId, Error>
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 rusqlite::Error if there was an error accessing the database.
§Examples
fn example(manager: &PostArchiverManager, post_id: PostId) -> Result<(), rusqlite::Error> {
let file_meta = UnsyncFileMeta {
filename: "image.jpg".to_string(),
mime: "image/jpeg".to_string(),
extra: HashMap::new(),
data: (),
};
let meta = manager.import_file_meta(post_id, &file_meta)?;
Ok(())
}Source§impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
Sourcepub fn import_post<U>(
&self,
post: UnsyncPost<U>,
update_relation: bool,
) -> Result<(PostId, Vec<AuthorId>, Vec<CollectionId>, Vec<(PathBuf, U)>), Error>
Available on crate feature importer only.
pub fn import_post<U>( &self, post: UnsyncPost<U>, update_relation: bool, ) -> Result<(PostId, Vec<AuthorId>, Vec<CollectionId>, Vec<(PathBuf, U)>), Error>
importer only.Import a post into the archive.
If the post already exists (by source), it updates its title, platform, published date,
§Parameters
update_relation: update the relations of authors and collections after importing.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
§Examples
let post: UnsyncPost<()> = UnsyncPost::new(PlatformId(1), "https://blog.example.com/post/1".to_string(), "My First Post".to_string(), vec![]);
let files_data = HashMap::<String,()>::new(); // You can provide file data if needed
let post = manager.import_post(post, true)?;
Ok(())Sourcepub fn import_posts<U>(
&self,
posts: impl IntoIterator<Item = UnsyncPost<U>>,
update_relation: bool,
) -> Result<(Vec<PostId>, Vec<(PathBuf, U)>), Error>
Available on crate feature importer only.
pub fn import_posts<U>( &self, posts: impl IntoIterator<Item = UnsyncPost<U>>, update_relation: bool, ) -> Result<(Vec<PostId>, Vec<(PathBuf, U)>), Error>
importer only.Import multiple posts into the archive.
This function processes each post, importing its authors, collections, and files.
§Parameters
update_relation: update the relations of authors and collections after importing.
§Errors
Returns rusqlite::Error if there was an error accessing the database.
§Examples
let posts: Vec<UnsyncPost<()>> = vec![
UnsyncPost::new(PlatformId(1), "https://blog.example.com/post/1".to_string(), "My First Post".to_string(), vec![]),
UnsyncPost::new(PlatformId(1), "https://blog.example.com/post/2".to_string(), "My Second Post".to_string(), vec![]),
];
let post = manager.import_posts(posts, true)?;
Ok(())Source§impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
impl<T> PostArchiverManager<T>where
T: PostArchiverConnection,
Sourcepub fn import_collection(
&self,
collection: UnsyncCollection,
) -> Result<CollectionId, Error>
Available on crate feature importer only.
pub fn import_collection( &self, collection: UnsyncCollection, ) -> Result<CollectionId, Error>
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 rusqlite::Error if there was an error accessing the database.
Sourcepub fn import_collections(
&self,
collections: impl IntoIterator<Item = UnsyncCollection>,
) -> Result<Vec<CollectionId>, Error>
Available on crate feature importer only.
pub fn import_collections( &self, collections: impl IntoIterator<Item = UnsyncCollection>, ) -> Result<Vec<CollectionId>, Error>
importer only.Import multiple collections into the archive.
This method takes an iterator of UnsyncCollection and imports each one.
§Errors
Returns rusqlite::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, Error>
Available on crate feature importer only.
pub fn import_tag(&self, tag: UnsyncTag) -> Result<TagId, Error>
importer only.Import a tag into the archive.
If the tag already exists, it returns the existing ID.
§Errors
Returns rusqlite::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 rusqlite::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, Error>
Available on crate feature importer only.
pub fn import_platform(&self, platform: String) -> Result<PlatformId, Error>
importer only.Import a platform into the archive.
If the platform already exists, it returns the existing ID.
§Errors
Returns rusqlite::Error if there was an error accessing the database.