use crate::{AuthorId, CollectionId, FileMetaId, PlatformId, PostId, TagId};
use super::{PostArchiverConnection, PostArchiverManager};
pub trait BindableId: Copy {}
impl BindableId for PostId {}
impl BindableId for AuthorId {}
impl BindableId for TagId {}
impl BindableId for PlatformId {}
impl BindableId for CollectionId {}
impl BindableId for FileMetaId {}
#[derive(Debug)]
pub struct Binded<'a, Id: BindableId, C: PostArchiverConnection = rusqlite::Connection> {
manager: &'a PostArchiverManager<C>,
id: Id,
}
impl<'a, Id: BindableId, C: PostArchiverConnection> Binded<'a, Id, C> {
pub fn new(manager: &'a PostArchiverManager<C>, id: Id) -> Self {
Self { manager, id }
}
pub fn id(&self) -> Id {
self.id
}
pub fn manager(&self) -> &'a PostArchiverManager<C> {
self.manager
}
pub fn conn(&self) -> &rusqlite::Connection {
self.manager.conn()
}
}