pub struct Database { /* private fields */ }Expand description
Struct holding a sqlite database connection, with methods to interact with this connection.
Implementations§
Source§impl Database
impl Database
Sourcepub fn new(path: &Path) -> Result<Database>
pub fn new(path: &Path) -> Result<Database>
Creates a new connection to the database (and creates database if it does not already exist).
§Errors
- if creating / opening the database fails
- if migration fails
Sourcepub fn insert_podcast(&self, podcast: &PodcastNoId) -> Result<u64>
pub fn insert_podcast(&self, podcast: &PodcastNoId) -> Result<u64>
Inserts a new podcast and list of podcast episodes into the database.
Sourcepub fn insert_episode(
conn: &Connection,
podcast_id: PodcastDBId,
episode: &EpisodeNoId,
) -> Result<PodcastDBId>
pub fn insert_episode( conn: &Connection, podcast_id: PodcastDBId, episode: &EpisodeNoId, ) -> Result<PodcastDBId>
Inserts a podcast episode into the database.
Sourcepub fn insert_file(&self, episode_id: PodcastDBId, path: &Path) -> Result<()>
pub fn insert_file(&self, episode_id: PodcastDBId, path: &Path) -> Result<()>
Inserts a filepath to a downloaded episode.
Sourcepub fn remove_file(&self, episode_id: PodcastDBId) -> Result<()>
pub fn remove_file(&self, episode_id: PodcastDBId) -> Result<()>
Removes a file listing for an episode from the database when the user has chosen to delete the file.
Sourcepub fn remove_files(&self, episode_ids: &[PodcastDBId]) -> Result<()>
pub fn remove_files(&self, episode_ids: &[PodcastDBId]) -> Result<()>
Removes all file listings for the selected episode ids.
Sourcepub fn remove_podcast(&self, podcast_id: PodcastDBId) -> Result<()>
pub fn remove_podcast(&self, podcast_id: PodcastDBId) -> Result<()>
Removes a podcast, all episodes, and files from the database.
Sourcepub fn update_podcast(
&self,
pod_id: PodcastDBId,
podcast: &PodcastNoId,
) -> Result<SyncResult>
pub fn update_podcast( &self, pod_id: PodcastDBId, podcast: &PodcastNoId, ) -> Result<SyncResult>
Updates an existing podcast in the database, where metadata is changed if necessary, and episodes are updated (modified episodes are updated, new episodes are inserted).
Sourcepub fn set_played_status(
&self,
episode_id: PodcastDBId,
played: bool,
) -> Result<()>
pub fn set_played_status( &self, episode_id: PodcastDBId, played: bool, ) -> Result<()>
Updates an episode to mark it as played or unplayed.
Sourcepub fn set_all_played_status(
&self,
episode_id_vec: &[PodcastDBId],
played: bool,
) -> Result<()>
pub fn set_all_played_status( &self, episode_id_vec: &[PodcastDBId], played: bool, ) -> Result<()>
Updates an episode to mark it as played or unplayed.
Sourcepub fn hide_episode(&self, episode_id: PodcastDBId, hide: bool) -> Result<()>
pub fn hide_episode(&self, episode_id: PodcastDBId, hide: bool) -> Result<()>
Updates an episode to “remove” it by hiding it. “Removed” episodes need to stay in the database so that they don’t get re-added when the podcast is synced again.
Sourcepub fn get_podcasts(&self) -> Result<Vec<Podcast>>
pub fn get_podcasts(&self) -> Result<Vec<Podcast>>
Generates list of all podcasts in database. TODO: This should probably use a JOIN statement instead.
Sourcepub fn get_episodes(
&self,
pod_id: PodcastDBId,
include_hidden: bool,
) -> Result<Vec<Episode>>
pub fn get_episodes( &self, pod_id: PodcastDBId, include_hidden: bool, ) -> Result<Vec<Episode>>
Generates list of episodes for a given podcast.
Sourcepub fn get_episode_by_url(&self, ep_uri: &str) -> Result<Episode>
pub fn get_episode_by_url(&self, ep_uri: &str) -> Result<Episode>
Find a single Episode by its Url.
pub fn get_last_position(&mut self, track: &Track) -> Result<Duration>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Database
impl !RefUnwindSafe for Database
impl Send for Database
impl !Sync for Database
impl Unpin for Database
impl !UnwindSafe for Database
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request