PostArchiverManager

Struct PostArchiverManager 

Source
pub struct PostArchiverManager<T = Connection> {
    pub path: PathBuf,
    /* private fields */
}
Available on crate feature 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: PathBuf

Implementations§

Source§

impl<T> PostArchiverManager<T>

Source

pub fn list_authors(&self) -> Result<Vec<Author>, Error>

Retrieve all authors in the archive.

§Errors

Returns rusqlite::Error if there was an error accessing the database.

Source

pub fn find_author( &self, aliases: &[impl FindAlias], ) -> Result<Option<AuthorId>, Error>

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"),
}
Source

pub fn get_author(&self, author: AuthorId) -> Result<Author, Error>

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>

Source

pub fn add_author( &self, name: String, updated: Option<DateTime<Utc>>, ) -> Result<AuthorId, Error>

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.

Source

pub fn remove_author(&self, author: AuthorId) -> Result<(), Error>

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.

Source

pub fn add_author_aliases( &self, author: AuthorId, aliases: Vec<(String, PlatformId, Option<String>)>, ) -> Result<(), Error>

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)
Source

pub fn remove_author_aliases( &self, author: AuthorId, aliases: &[(String, PlatformId)], ) -> Result<(), Error>

Remove aliases for an author.

Deletes the specified aliases for the given author. If an alias does not exist, it will be ignored.

§Parameters
  • aliases[..]: (Source, Platform)
§Errors

Returns rusqlite::Error if there was an error accessing the database.

Source

pub fn set_author_alias_name( &self, author: AuthorId, alias: &(String, PlatformId), name: String, ) -> Result<(), Error>

Set an name of author’s alias.

§Parameters
  • alias: (Source, Platform)
§Errors

Returns rusqlite::Error if there was an error accessing the database.

Source

pub fn set_author_alias_platform( &self, author: AuthorId, alias: &(String, PlatformId), platform: PlatformId, ) -> Result<(), Error>

Set an platform of author’s alias.

§Parameters
  • alias: (Source, Platform)
§Errors

Returns rusqlite::Error if there was an error accessing the database.

Set a link of author’s alias.

§Parameters
  • alias: (Source, Platform)
§Errors

Returns rusqlite::Error if there was an error accessing the database.

Source

pub fn set_author_name( &self, author: AuthorId, name: String, ) -> Result<(), Error>

Set an name of author.

§Errors

Returns rusqlite::Error if there was an error accessing the database.

Source

pub fn set_author_thumb( &self, author: AuthorId, thumb: Option<FileMetaId>, ) -> Result<(), Error>

Set a thumb of author.

§Errors

Returns rusqlite::Error if there was an error accessing the database.

Source

pub fn set_author_thumb_by_latest(&self, author: AuthorId) -> Result<(), Error>

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.

Source

pub fn set_author_updated( &self, author: AuthorId, updated: DateTime<Utc>, ) -> Result<(), Error>

Set the updated timestamp of an author.

§Errors

Returns rusqlite::Error if there was an error accessing the database.

Source

pub fn set_author_updated_by_latest( &self, author: AuthorId, ) -> Result<(), Error>

Source§

impl<T> PostArchiverManager<T>

Source

pub fn list_author_aliases(&self, author: AuthorId) -> Result<Vec<Alias>, Error>

Retrieve all aliases associated with an author.

§Errors

Returns rusqlite::Error if there was an error accessing the database.

Source

pub fn list_author_posts(&self, author: AuthorId) -> Result<Vec<Post>, Error>

Retrieve all posts associated with an author.

§Errors

Returns rusqlite::Error if there was an error accessing the database.

Source

pub fn list_post_authors(&self, post: &PostId) -> Result<Vec<Author>, Error>

Retrieve all authors associated with a post.

§Errors

Returns rusqlite::Error if there was an error accessing the database.

Source§

impl<T> PostArchiverManager<T>

Source

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.

Source

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.

Source

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>

Source

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
Source

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.

Source

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.

Source

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.
Source

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.
Source

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>

Source

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.

Source

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>

Source

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.

Source

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>

Source

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
Source

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.

Source

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.

Source

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>

Source

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.

Source

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.

Source

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>

Source

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
Source

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.

Source

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>

Source

pub fn list_platform_tags( &self, platform: &Option<PlatformId>, ) -> Result<Vec<Tag>, Error>

List all tags associated with a platform.

§Errors

Returns rusqlite::Error if there was an error accessing the database.

Source

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>

Source

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.

Source

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

pub fn find_post_with_updated( &self, source: &str, updated: &DateTime<Utc>, ) -> Result<Option<PostId>, Error>

Find a post by its source.

If you want to check if the post exists in the archive, use find_post instead.

§errors

Returns rusqlite::error if there was an error accessing the database. Check if a the post exists in the archive by their source and updated date.

Source

pub fn get_post(&self, id: &PostId) -> Result<Post, Error>

Retrieve a post by its ID.

§Errors

Returns rusqlite::Error if:

  • The post ID does not exist
  • There was an error accessing the database
Source§

impl<T> PostArchiverManager<T>

Source

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
Source

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.

Source

pub fn add_post_authors( &self, post: PostId, authors: &[AuthorId], ) -> Result<(), Error>

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.

Source

pub fn remove_post_authors( &self, post: PostId, authors: &[AuthorId], ) -> Result<(), Error>

Remove one or more authors from a post.

§Errors

Returns rusqlite::Error if there was an error accessing the database.

Source

pub fn add_post_tags(&self, post: PostId, tags: &[TagId]) -> 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.

Source

pub fn remove_post_tags( &self, post: PostId, tags: &[TagId], ) -> Result<(), Error>

Remove one or more tags from a post.

§Errors

Returns rusqlite::Error if there was an error accessing the database.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

pub fn set_post_updated( &self, post: PostId, updated: DateTime<Utc>, ) -> Result<(), Error>

Set a post’s updated timestamp.

§Errors

Returns rusqlite::Error if there was an error accessing the database.

Source

pub fn set_post_updated_by_latest( &self, post: PostId, updated: DateTime<Utc>, ) -> Result<(), Error>

Set a post’s updated timestamp if current timestamp is more recent.

§Errors

Returns rusqlite::Error if there was an error accessing the database.

Source§

impl<T> PostArchiverManager<T>

Source

pub fn list_tags(&self) -> Result<Vec<Tag>, Error>

Retrieve all tags in the archive.

§Errors

Returns rusqlite::Error if there was an error accessing the database.

Source

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

pub fn get_tag(&self, tag: &TagId) -> Result<Option<Tag>, Error>

Retrieve a tag by its ID.

§Errors

Returns rusqlite::Error if:

  • The tag ID does not exist
  • There was an error accessing the database
Source§

impl<T> PostArchiverManager<T>

Source

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
Source

pub fn remove_tag(&self, tag: &TagId) -> Result<(), Error>

Remove a tag from the archive.

This will delete the posts associated with the tag as well, but will not delete the posts themselves.

§Errors
§Returns rusqlite::Error if:
  • The tag ID does not exist
  • There was an error accessing the database
Source

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.

Source

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>

Source

pub fn list_post_tags(&self, post: &PostId) -> Result<Vec<Tag>, Error>

List all tags associated with a post.

§Errors

Returns rusqlite::Error if there was an error accessing the database.

Source

pub fn list_tag_posts(&self, tag: &TagId) -> Result<Vec<Post>, Error>

List all posts associated with a tag.

§Errors

Returns rusqlite::Error if there was an error accessing the database.

Source§

impl PostArchiverManager

Source

pub fn create<P>(path: P) -> Result<Self, Error>
where P: AsRef<Path>,

Creates a new archive at the specified path

§Safety

The path must not already contain a database file.

§Examples
use post_archiver::manager::PostArchiverManager;

let manager = PostArchiverManager::create("./new_archive").unwrap();
Source

pub fn open<P>(path: P) -> Result<Option<Self>, Error>
where P: AsRef<Path>,

Opens an existing archive at the specified path

§Returns
  • Ok(Some(manager)) if archive exists and version is compatible
  • Ok(None) if archive doesn’t exist
  • Err(_) on database errors
§Examples
use post_archiver::manager::PostArchiverManager;

if let Some(manager) = PostArchiverManager::open("./archive").unwrap() {
    println!("Archive opened successfully");
}
Source

pub fn open_uncheck<P>(path: P) -> Result<Option<Self>, Error>
where P: AsRef<Path>,

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 compatible
  • Ok(None) if archive doesn’t exist
  • Err(_) on database errors
§Examples
use post_archiver::manager::PostArchiverManager;

if let Some(manager) = PostArchiverManager::open_uncheck("./archive").unwrap() {
    println!("Archive opened successfully");
}
Source

pub fn open_or_create<P>(path: P) -> Result<Self, Error>
where P: AsRef<Path>,

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();
Source

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();
Source

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<'_>>

Source

pub fn commit(self) -> Result<(), Error>

Commits the transaction

Source§

impl<T> PostArchiverManager<T>

Source

pub fn conn(&self) -> &Connection

Source

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);
Source

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);
Source

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

pub fn set_feature_with_extra( &self, name: &str, value: i64, extra: HashMap<String, Value>, )

Set feature value and extra data by name.

if it exists, its value and extra data will be updated.

§Errors

Returns rusqlite::Error if there was an error accessing the database.

Source§

impl<T> PostArchiverManager<T>

Source

pub fn import_author(&self, author: UnsyncAuthor) -> Result<AuthorId, Error>

Available on crate feature 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>

Source

pub fn import_file_meta<U>( &self, post: PostId, file_meta: &UnsyncFileMeta<U>, ) -> Result<FileMetaId, Error>

Available on crate feature 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>

Source

pub 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.

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(())
Source

pub 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.

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>

Source

pub fn import_collection( &self, collection: UnsyncCollection, ) -> Result<CollectionId, Error>

Available on crate feature 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.

Source

pub fn import_collections( &self, collections: impl IntoIterator<Item = UnsyncCollection>, ) -> Result<Vec<CollectionId>, Error>

Available on crate feature 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>

Source

pub fn import_tag(&self, tag: UnsyncTag) -> Result<TagId, Error>

Available on crate feature 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.

Source

pub fn import_tags( &self, tags: impl IntoIterator<Item = UnsyncTag>, ) -> Result<Vec<TagId>, Error>

Available on crate feature 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>

Source

pub fn import_platform(&self, platform: String) -> Result<PlatformId, Error>

Available on crate feature 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.

Trait Implementations§

Source§

impl<T: Debug> Debug for PostArchiverManager<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for PostArchiverManager<T>
where T: Freeze,

§

impl<T = Connection> !RefUnwindSafe for PostArchiverManager<T>

§

impl<T> Send for PostArchiverManager<T>
where T: Send,

§

impl<T> Sync for PostArchiverManager<T>
where T: Sync,

§

impl<T> Unpin for PostArchiverManager<T>
where T: Unpin,

§

impl<T = Connection> !UnwindSafe for PostArchiverManager<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.