refactor(gpodder): rename store trait
This commit is contained in:
parent
fc46c4874a
commit
7de4897364
7 changed files with 18 additions and 16 deletions
|
|
@ -5,5 +5,6 @@ mod store;
|
|||
pub use models::*;
|
||||
pub use repository::GpodderRepository;
|
||||
pub use store::{
|
||||
AuthErr, AuthStore, DeviceRepository, EpisodeActionRepository, Store, SubscriptionRepository,
|
||||
AuthErr, GpodderAuthStore, GpodderDeviceStore, GpodderEpisodeActionStore, GpodderStore,
|
||||
GpodderSubscriptionStore,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,18 +6,18 @@ use rand::{Rng, rngs::OsRng};
|
|||
|
||||
use crate::{
|
||||
models,
|
||||
store::{AuthErr, Store},
|
||||
store::{AuthErr, GpodderStore},
|
||||
};
|
||||
|
||||
const MAX_SESSION_AGE: i64 = 60 * 60 * 24 * 7;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct GpodderRepository {
|
||||
store: Arc<dyn Store + Send + Sync>,
|
||||
store: Arc<dyn GpodderStore + Send + Sync>,
|
||||
}
|
||||
|
||||
impl GpodderRepository {
|
||||
pub fn new(store: impl Store + Send + Sync + 'static) -> Self {
|
||||
pub fn new(store: impl GpodderStore + Send + Sync + 'static) -> Self {
|
||||
Self {
|
||||
store: Arc::new(store),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,17 +24,18 @@ impl Display for AuthErr {
|
|||
|
||||
impl std::error::Error for AuthErr {}
|
||||
|
||||
pub trait Store:
|
||||
AuthStore + DeviceRepository + SubscriptionRepository + EpisodeActionRepository
|
||||
/// API abstraction providing methods for serving the Gpodder API
|
||||
pub trait GpodderStore:
|
||||
GpodderAuthStore + GpodderDeviceStore + GpodderSubscriptionStore + GpodderEpisodeActionStore
|
||||
{
|
||||
}
|
||||
|
||||
impl<T> Store for T where
|
||||
T: AuthStore + DeviceRepository + SubscriptionRepository + EpisodeActionRepository
|
||||
impl<T> GpodderStore for T where
|
||||
T: GpodderAuthStore + GpodderDeviceStore + GpodderSubscriptionStore + GpodderEpisodeActionStore
|
||||
{
|
||||
}
|
||||
|
||||
pub trait AuthStore {
|
||||
pub trait GpodderAuthStore {
|
||||
/// Retrieve the session with the given session ID
|
||||
fn get_session(&self, session_id: i64) -> Result<Option<Session>, AuthErr>;
|
||||
|
||||
|
|
@ -63,7 +64,7 @@ pub trait AuthStore {
|
|||
fn remove_old_sessions(&self, min_last_seen: DateTime<Utc>) -> Result<usize, AuthErr>;
|
||||
}
|
||||
|
||||
pub trait DeviceRepository {
|
||||
pub trait GpodderDeviceStore {
|
||||
/// Return all devices associated with the user
|
||||
fn devices_for_user(&self, user: &User) -> Result<Vec<Device>, AuthErr>;
|
||||
|
||||
|
|
@ -108,7 +109,7 @@ pub trait DeviceRepository {
|
|||
) -> Result<(Vec<String>, Vec<Vec<String>>), AuthErr>;
|
||||
}
|
||||
|
||||
pub trait SubscriptionRepository {
|
||||
pub trait GpodderSubscriptionStore {
|
||||
/// Return the subscriptions for the given device
|
||||
fn subscriptions_for_device(
|
||||
&self,
|
||||
|
|
@ -149,7 +150,7 @@ pub trait SubscriptionRepository {
|
|||
) -> Result<(Vec<Subscription>, Vec<Subscription>), AuthErr>;
|
||||
}
|
||||
|
||||
pub trait EpisodeActionRepository {
|
||||
pub trait GpodderEpisodeActionStore {
|
||||
/// Insert the given episode actions into the datastore.
|
||||
fn add_episode_actions(
|
||||
&self,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue