Skip to main content

Binded

Struct Binded 

Source
pub struct Binded<'a, Id: BindableId, C: PostArchiverConnection = Connection> { /* private fields */ }
Available on crate feature utils only.
Expand description

A bound entity context for update, delete, and relation operations.

Created via PostArchiverManager::bind(id). The Id type parameter is inferred from the argument — no turbofish needed.

§Examples

// Binded<'_, PostId, _> — type inferred from post_id
manager.bind(post_id).delete()?;

Implementations§

Source§

impl<'a, Id: BindableId, C: PostArchiverConnection> Binded<'a, Id, C>

Source

pub fn new(manager: &'a PostArchiverManager<C>, id: Id) -> Self

Source

pub fn id(&self) -> Id

Returns the bound entity ID.

Source

pub fn manager(&self) -> &'a PostArchiverManager<C>

Returns a reference to the underlying manager.

Source

pub fn conn(&self) -> &Connection

Shortcut: returns a reference to the database connection.

Source§

impl<'a, C: PostArchiverConnection> Binded<'a, AuthorId, C>

Source

pub fn value(&self) -> Result<Author>

Get this author’s current data from the database.

Source

pub fn delete(self) -> Result<()>

Remove this author from the archive.

This also removes all associated aliases and author-post relationships.

Source

pub fn update(&self, update: UpdateAuthor) -> Result<()>

Apply a batch of field updates to this author in a single SQL statement.

Only fields set on update (i.e. Some(...)) are written to the database.

Source§

impl<'a, C: PostArchiverConnection> Binded<'a, AuthorId, C>

Source

pub fn list_aliases(&self) -> Result<Vec<Alias>>

List all aliases associated with this author.

Source

pub fn add_aliases( &self, aliases: Vec<(String, PlatformId, Option<String>)>, ) -> Result<()>

Add or update aliases for this author.

§Parameters
  • aliases: Vec of (source, platform, link)
Source

pub fn remove_aliases(&self, aliases: &[(String, PlatformId)]) -> Result<()>

Remove aliases from this author.

§Parameters
  • aliases: &[(source, platform)]
Source

pub fn set_alias_name( &self, alias: &(String, PlatformId), name: String, ) -> Result<()>

Set an alias’s name.

Source

pub fn set_alias_platform( &self, alias: &(String, PlatformId), platform: PlatformId, ) -> Result<()>

Set an alias’s platform.

Set an alias’s link.

Source§

impl<'a, C: PostArchiverConnection> Binded<'a, AuthorId, C>

Source

pub fn list_posts(&self) -> Result<Vec<PostId>>

List all post IDs associated with this author.

Source§

impl<'a, C: PostArchiverConnection> Binded<'a, CollectionId, C>

Source

pub fn value(&self) -> Result<Collection>

Get this collection’s current data from the database.

Source

pub fn delete(self) -> Result<()>

Remove this collection from the archive.

Also removes all collection-post relationships.

Source

pub fn update(&self, update: UpdateCollection) -> Result<()>

Apply a batch of field updates to this collection in a single SQL statement.

Only fields set on update (i.e. Some(...)) are written to the database.

Source§

impl<'a, C: PostArchiverConnection> Binded<'a, CollectionId, C>

Source

pub fn list_posts(&self) -> Result<Vec<PostId>>

List all post IDs in this collection.

Source

pub fn add_posts(&self, posts: &[PostId]) -> Result<()>

Add posts to this collection.

Source

pub fn remove_posts(&self, posts: &[PostId]) -> Result<()>

Remove posts from this collection.

Source§

impl<'a, C: PostArchiverConnection> Binded<'a, FileMetaId, C>

Source

pub fn value(&self) -> Result<FileMeta>

Get this file metadata’s current data from the database.

Source

pub fn delete(self) -> Result<()>

Remove this 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.

Source

pub fn update<T>(&self, update: UpdateFileMeta<T>) -> Result<()>

Apply a batch of field updates to this file metadata in a single SQL statement.

Only fields set on update (i.e. Some(...)) are written to the database.

Source

pub fn update_with_content<T>(&self, update: UpdateFileMeta<T>) -> Result<()>

Source

pub fn get_path(&self) -> Result<PathBuf>

Get the file path of this file metadata.

Source§

impl<'a, C: PostArchiverConnection> Binded<'a, PlatformId, C>

Source

pub fn value(&self) -> Result<Platform>

Get this platform’s current data from the database.

Source

pub fn delete(self) -> Result<()>

Remove this platform from the archive.

This operation will also set the platform to UNKNOWN for all author aliases and posts. Tags associated with the platform will be deleted.

Source

pub fn update(&self, update: UpdatePlatform) -> Result<()>

Apply a batch of field updates to this platform in a single SQL statement.

Only fields set on update (i.e. Some(...)) are written to the database.

Source§

impl<'a, C: PostArchiverConnection> Binded<'a, PlatformId, C>

Source

pub fn list_tags(&self) -> Result<Vec<TagId>>

List all tag IDs associated with this platform.

Source

pub fn list_posts(&self) -> Result<Vec<PostId>>

List all post IDs associated with this platform.

Source§

impl<'a, C: PostArchiverConnection> Binded<'a, PostId, C>

Source

pub fn value(&self) -> Result<Post>

Get this post’s current data from the database.

Source

pub fn delete(self) -> Result<()>

Remove this post from the archive.

This also removes all associated file metadata, author associations, tag associations, and collection associations.

Source

pub fn update(&self, update: UpdatePost) -> Result<()>

Apply a batch of field updates to this post in a single SQL statement.

Only fields set on update (i.e. Some(...)) are written to the database.

Source

pub fn list_file_metas(&self) -> Result<Vec<FileMetaId>>

List all file metadata IDs associated with this post.

Source§

impl<'a, C: PostArchiverConnection> Binded<'a, PostId, C>

Source

pub fn list_authors(&self) -> Result<Vec<AuthorId>>

List all author IDs associated with this post.

Source

pub fn add_authors(&self, authors: &[AuthorId]) -> Result<()>

Associate one or more authors with this post. Duplicate associations are silently ignored.

Source

pub fn remove_authors(&self, authors: &[AuthorId]) -> Result<()>

Remove one or more authors from this post.

Source§

impl<'a, C: PostArchiverConnection> Binded<'a, PostId, C>

Source

pub fn list_tags(&self) -> Result<Vec<TagId>>

List all tag IDs associated with this post.

Source

pub fn add_tags(&self, tags: &[TagId]) -> Result<()>

Associate one or more tags with this post. Duplicate associations are silently ignored.

Source

pub fn remove_tags(&self, tags: &[TagId]) -> Result<()>

Remove one or more tags from this post.

Source§

impl<'a, C: PostArchiverConnection> Binded<'a, PostId, C>

Source

pub fn list_collections(&self) -> Result<Vec<CollectionId>>

List all collection IDs associated with this post.

Source

pub fn add_collections(&self, collections: &[CollectionId]) -> Result<()>

Associate one or more collections with this post. Duplicate associations are silently ignored.

Source

pub fn remove_collections(&self, collections: &[CollectionId]) -> Result<()>

Remove one or more collections from this post.

Source§

impl<'a, C: PostArchiverConnection> Binded<'a, TagId, C>

Source

pub fn value(&self) -> Result<Tag>

Get this tag’s current data from the database.

Source

pub fn delete(self) -> Result<()>

Remove this tag from the archive.

This will also remove all post-tag relationships, but will not delete the posts themselves.

Source

pub fn update(&self, update: UpdateTag) -> Result<()>

Apply a batch of field updates to this tag in a single SQL statement.

Only fields set on update (i.e. Some(...)) are written to the database.

Source§

impl<'a, C: PostArchiverConnection> Binded<'a, TagId, C>

Source

pub fn list_posts(&self) -> Result<Vec<PostId>>

List all post IDs associated with this tag.

Trait Implementations§

Source§

impl<'a, Id: Debug + BindableId, C: Debug + PostArchiverConnection> Debug for Binded<'a, Id, C>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, Id, C> Freeze for Binded<'a, Id, C>
where Id: Freeze,

§

impl<'a, Id, C> RefUnwindSafe for Binded<'a, Id, C>

§

impl<'a, Id, C> Send for Binded<'a, Id, C>
where Id: Send, C: Sync,

§

impl<'a, Id, C> Sync for Binded<'a, Id, C>
where Id: Sync, C: Sync,

§

impl<'a, Id, C> Unpin for Binded<'a, Id, C>
where Id: Unpin,

§

impl<'a, Id, C> UnsafeUnpin for Binded<'a, Id, C>
where Id: UnsafeUnpin,

§

impl<'a, Id, C> UnwindSafe for Binded<'a, Id, C>
where Id: UnwindSafe, C: RefUnwindSafe,

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.