pub struct MediaStore { /* private fields */ }Expand description
SQLite-backed persistence for media data.
Family membership remains owned by agent-storage; this store only scopes
media records by the authoritative family ID supplied by the application.
Implementations§
Source§impl MediaStore
impl MediaStore
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self, MediaStoreError>
pub fn open(path: impl AsRef<Path>) -> Result<Self, MediaStoreError>
Open or create a media database at path.
Sourcepub fn open_in_memory() -> Result<Self, MediaStoreError>
pub fn open_in_memory() -> Result<Self, MediaStoreError>
Create an isolated in-memory media database (primarily useful in tests).
Sourcepub async fn save_profile(
&self,
profile: &MediaProfile,
) -> Result<(), MediaStoreError>
pub async fn save_profile( &self, profile: &MediaProfile, ) -> Result<(), MediaStoreError>
Insert or update a media profile without changing its ownership scope.
Sourcepub async fn get_or_create_personal_profile(
&self,
owner_id: UserId,
) -> Result<MediaProfile, MediaStoreError>
pub async fn get_or_create_personal_profile( &self, owner_id: UserId, ) -> Result<MediaProfile, MediaStoreError>
Return the user’s personal profile, creating it exactly once when absent.
Sourcepub async fn get_personal_profile(
&self,
owner_id: UserId,
profile_id: MediaProfileId,
) -> Result<Option<MediaProfile>, MediaStoreError>
pub async fn get_personal_profile( &self, owner_id: UserId, profile_id: MediaProfileId, ) -> Result<Option<MediaProfile>, MediaStoreError>
Load a personal profile only when it is owned by the requesting EME user.
Sourcepub async fn list_profiles(
&self,
family_id: FamilyId,
) -> Result<Vec<MediaProfile>, MediaStoreError>
pub async fn list_profiles( &self, family_id: FamilyId, ) -> Result<Vec<MediaProfile>, MediaStoreError>
List profiles belonging to one family; no membership data is duplicated here.
Sourcepub async fn get_profile(
&self,
family_id: FamilyId,
profile_id: MediaProfileId,
) -> Result<Option<MediaProfile>, MediaStoreError>
pub async fn get_profile( &self, family_id: FamilyId, profile_id: MediaProfileId, ) -> Result<Option<MediaProfile>, MediaStoreError>
Load a profile only within the requested family boundary.
Sourcepub async fn delete_profile(
&self,
family_id: FamilyId,
profile_id: MediaProfileId,
) -> Result<(), MediaStoreError>
pub async fn delete_profile( &self, family_id: FamilyId, profile_id: MediaProfileId, ) -> Result<(), MediaStoreError>
Remove a profile and its dependent preferences and activity.
pub async fn save_profile_preferences( &self, preferences: &ProfilePreferences, ) -> Result<(), MediaStoreError>
pub async fn get_profile_preferences( &self, profile_id: MediaProfileId, ) -> Result<Option<ProfilePreferences>, MediaStoreError>
pub async fn save_content_restrictions( &self, restrictions: &ContentRestrictions, ) -> Result<(), MediaStoreError>
pub async fn get_content_restrictions( &self, profile_id: MediaProfileId, ) -> Result<Option<ContentRestrictions>, MediaStoreError>
pub async fn save_family_preferences( &self, preferences: &FamilyMediaPreferences, ) -> Result<(), MediaStoreError>
pub async fn get_family_preferences( &self, family_id: FamilyId, ) -> Result<Option<FamilyMediaPreferences>, MediaStoreError>
pub async fn save_media_item( &self, item: &MediaItem, ) -> Result<(), MediaStoreError>
pub async fn get_media_item( &self, id: MediaItemId, ) -> Result<Option<MediaItem>, MediaStoreError>
Sourcepub async fn record_watch_event(
&self,
event: &MediaWatchEvent,
) -> Result<(), MediaStoreError>
pub async fn record_watch_event( &self, event: &MediaWatchEvent, ) -> Result<(), MediaStoreError>
Record a viewing event idempotently (same profile, item, timestamp and source).
pub async fn list_watch_history( &self, profile_id: MediaProfileId, ) -> Result<Vec<MediaWatchEvent>, MediaStoreError>
Sourcepub async fn save_rating(
&self,
rating: &MediaRating,
) -> Result<(), MediaStoreError>
pub async fn save_rating( &self, rating: &MediaRating, ) -> Result<(), MediaStoreError>
Store a profile rating, replacing the previous rating from the same source.
pub async fn list_ratings( &self, profile_id: MediaProfileId, ) -> Result<Vec<MediaRating>, MediaStoreError>
pub async fn save_streaming_offer( &self, offer: &StreamingOffer, ) -> Result<(), MediaStoreError>
pub async fn list_streaming_offers( &self, item_id: MediaItemId, region: &str, ) -> Result<Vec<StreamingOffer>, MediaStoreError>
Sourcepub async fn create_pending_trakt_link(
&self,
state: &str,
pending: &PendingTraktLink,
expires_at: DateTime<Utc>,
) -> Result<(), MediaStoreError>
pub async fn create_pending_trakt_link( &self, state: &str, pending: &PendingTraktLink, expires_at: DateTime<Utc>, ) -> Result<(), MediaStoreError>
Persist a short-lived, hashed OAuth state bound to the initiating user and profile.
pub async fn get_pending_trakt_link( &self, state: &str, ) -> Result<PendingTraktLink, MediaStoreError>
Sourcepub async fn consume_pending_trakt_link(
&self,
state: &str,
now: DateTime<Utc>,
) -> Result<PendingTraktLink, MediaStoreError>
pub async fn consume_pending_trakt_link( &self, state: &str, now: DateTime<Utc>, ) -> Result<PendingTraktLink, MediaStoreError>
Consume a pending Trakt state exactly once and reject expired attempts.
Sourcepub async fn save_external_connection_link(
&self,
link: &MediaExternalConnectionLink,
) -> Result<(), MediaStoreError>
pub async fn save_external_connection_link( &self, link: &MediaExternalConnectionLink, ) -> Result<(), MediaStoreError>
Associate a profile with an existing encrypted EME external connection.
pub async fn get_external_connection_link( &self, profile_id: MediaProfileId, provider: &str, ) -> Result<Option<MediaExternalConnectionLink>, MediaStoreError>
Sourcepub async fn delete_external_connection_link(
&self,
profile_id: MediaProfileId,
provider: &str,
) -> Result<(), MediaStoreError>
pub async fn delete_external_connection_link( &self, profile_id: MediaProfileId, provider: &str, ) -> Result<(), MediaStoreError>
Remove a profile’s provider link; token revocation remains the caller’s responsibility.
pub async fn save_watchlist_item( &self, item: &MediaWatchlistItem, ) -> Result<(), MediaStoreError>
pub async fn list_watchlist( &self, profile_id: MediaProfileId, ) -> Result<Vec<MediaWatchlistItem>, MediaStoreError>
Sourcepub async fn replace_watchlist(
&self,
profile_id: MediaProfileId,
source: WatchHistorySource,
items: &[MediaWatchlistItem],
) -> Result<(), MediaStoreError>
pub async fn replace_watchlist( &self, profile_id: MediaProfileId, source: WatchHistorySource, items: &[MediaWatchlistItem], ) -> Result<(), MediaStoreError>
Replace a provider’s watchlist atomically so removals are reflected locally.
Sourcepub async fn replace_ratings(
&self,
profile_id: MediaProfileId,
source: WatchHistorySource,
ratings: &[MediaRating],
) -> Result<(), MediaStoreError>
pub async fn replace_ratings( &self, profile_id: MediaProfileId, source: WatchHistorySource, ratings: &[MediaRating], ) -> Result<(), MediaStoreError>
Replace all ratings from one provider after a full provider snapshot.