pub struct Binded<'a, Id: BindableId, C: PostArchiverConnection = Connection> { /* private fields */ }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>
impl<'a, Id: BindableId, C: PostArchiverConnection> Binded<'a, Id, C>
pub fn new(manager: &'a PostArchiverManager<C>, id: Id) -> Self
Sourcepub fn manager(&self) -> &'a PostArchiverManager<C>
pub fn manager(&self) -> &'a PostArchiverManager<C>
Returns a reference to the underlying manager.
Sourcepub fn conn(&self) -> &Connection
pub fn conn(&self) -> &Connection
Shortcut: returns a reference to the database connection.
Source§impl<'a, C: PostArchiverConnection> Binded<'a, AuthorId, C>
impl<'a, C: PostArchiverConnection> Binded<'a, AuthorId, C>
Sourcepub fn delete(self) -> Result<()>
pub fn delete(self) -> Result<()>
Remove this author from the archive.
This also removes all associated aliases and author-post relationships.
Sourcepub fn update(&self, update: UpdateAuthor) -> Result<()>
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>
impl<'a, C: PostArchiverConnection> Binded<'a, AuthorId, C>
Sourcepub fn list_aliases(&self) -> Result<Vec<Alias>>
pub fn list_aliases(&self) -> Result<Vec<Alias>>
List all aliases associated with this author.
Sourcepub fn add_aliases(
&self,
aliases: Vec<(String, PlatformId, Option<String>)>,
) -> Result<()>
pub fn add_aliases( &self, aliases: Vec<(String, PlatformId, Option<String>)>, ) -> Result<()>
Sourcepub fn remove_aliases(&self, aliases: &[(String, PlatformId)]) -> Result<()>
pub fn remove_aliases(&self, aliases: &[(String, PlatformId)]) -> Result<()>
Sourcepub fn set_alias_name(
&self,
alias: &(String, PlatformId),
name: String,
) -> Result<()>
pub fn set_alias_name( &self, alias: &(String, PlatformId), name: String, ) -> Result<()>
Set an alias’s name.
Sourcepub fn set_alias_platform(
&self,
alias: &(String, PlatformId),
platform: PlatformId,
) -> Result<()>
pub fn set_alias_platform( &self, alias: &(String, PlatformId), platform: PlatformId, ) -> Result<()>
Set an alias’s platform.
Sourcepub fn set_alias_link(
&self,
alias: &(String, PlatformId),
link: Option<String>,
) -> Result<()>
pub fn set_alias_link( &self, alias: &(String, PlatformId), link: Option<String>, ) -> Result<()>
Set an alias’s link.
Source§impl<'a, C: PostArchiverConnection> Binded<'a, AuthorId, C>
impl<'a, C: PostArchiverConnection> Binded<'a, AuthorId, C>
Sourcepub fn list_posts(&self) -> Result<Vec<PostId>>
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>
impl<'a, C: PostArchiverConnection> Binded<'a, CollectionId, C>
Sourcepub fn value(&self) -> Result<Collection>
pub fn value(&self) -> Result<Collection>
Get this collection’s current data from the database.
Sourcepub fn delete(self) -> Result<()>
pub fn delete(self) -> Result<()>
Remove this collection from the archive.
Also removes all collection-post relationships.
Sourcepub fn update(&self, update: UpdateCollection) -> Result<()>
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>
impl<'a, C: PostArchiverConnection> Binded<'a, CollectionId, C>
Source§impl<'a, C: PostArchiverConnection> Binded<'a, FileMetaId, C>
impl<'a, C: PostArchiverConnection> Binded<'a, FileMetaId, C>
Sourcepub fn value(&self) -> Result<FileMeta>
pub fn value(&self) -> Result<FileMeta>
Get this file metadata’s current data from the database.
Sourcepub fn delete(self) -> Result<()>
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.
Sourcepub fn update<T>(&self, update: UpdateFileMeta<T>) -> Result<()>
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.
pub fn update_with_content<T>(&self, update: UpdateFileMeta<T>) -> Result<()>where
T: WritableFileMeta,
Source§impl<'a, C: PostArchiverConnection> Binded<'a, PlatformId, C>
impl<'a, C: PostArchiverConnection> Binded<'a, PlatformId, C>
Sourcepub fn delete(self) -> Result<()>
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.
Sourcepub fn update(&self, update: UpdatePlatform) -> Result<()>
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>
impl<'a, C: PostArchiverConnection> Binded<'a, PlatformId, C>
List all tag IDs associated with this platform.
Sourcepub fn list_posts(&self) -> Result<Vec<PostId>>
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>
impl<'a, C: PostArchiverConnection> Binded<'a, PostId, C>
Sourcepub fn delete(self) -> Result<()>
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.
Sourcepub fn update(&self, update: UpdatePost) -> Result<()>
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.
Sourcepub fn list_file_metas(&self) -> Result<Vec<FileMetaId>>
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>
impl<'a, C: PostArchiverConnection> Binded<'a, PostId, C>
List all author IDs associated with this post.
Associate one or more authors with this post. Duplicate associations are silently ignored.
Remove one or more authors from this post.
Source§impl<'a, C: PostArchiverConnection> Binded<'a, PostId, C>
impl<'a, C: PostArchiverConnection> Binded<'a, PostId, C>
List all tag IDs associated with this post.
Associate one or more tags with this post. Duplicate associations are silently ignored.
Remove one or more tags from this post.
Source§impl<'a, C: PostArchiverConnection> Binded<'a, PostId, C>
impl<'a, C: PostArchiverConnection> Binded<'a, PostId, C>
Sourcepub fn list_collections(&self) -> Result<Vec<CollectionId>>
pub fn list_collections(&self) -> Result<Vec<CollectionId>>
List all collection IDs associated with this post.
Sourcepub fn add_collections(&self, collections: &[CollectionId]) -> Result<()>
pub fn add_collections(&self, collections: &[CollectionId]) -> Result<()>
Associate one or more collections with this post. Duplicate associations are silently ignored.
Sourcepub fn remove_collections(&self, collections: &[CollectionId]) -> Result<()>
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>
impl<'a, C: PostArchiverConnection> Binded<'a, TagId, C>
Source§impl<'a, C: PostArchiverConnection> Binded<'a, TagId, C>
impl<'a, C: PostArchiverConnection> Binded<'a, TagId, C>
Sourcepub fn list_posts(&self) -> Result<Vec<PostId>>
pub fn list_posts(&self) -> Result<Vec<PostId>>
List all post IDs associated with this tag.