pub struct TraktSyncService { /* private fields */ }Expand description
Incremental, profile-scoped Trakt data synchronization.
Implementations§
Source§impl TraktSyncService
impl TraktSyncService
pub fn new( media: MediaStore, token_manager: TraktTokenManager, client_id: impl Into<String>, ) -> Result<Self, TraktSyncError>
Sourcepub fn with_base_url(
media: MediaStore,
token_manager: TraktTokenManager,
client_id: impl Into<String>,
api_base_url: impl Into<String>,
) -> Result<Self, TraktSyncError>
pub fn with_base_url( media: MediaStore, token_manager: TraktTokenManager, client_id: impl Into<String>, api_base_url: impl Into<String>, ) -> Result<Self, TraktSyncError>
Custom API endpoint supports deterministic tests and compatible deployments.
Sourcepub async fn sync_profile(
&self,
owner_id: UserId,
profile_id: MediaProfileId,
) -> Result<TraktSyncSummary, TraktSyncError>
pub async fn sync_profile( &self, owner_id: UserId, profile_id: MediaProfileId, ) -> Result<TraktSyncSummary, TraktSyncError>
Sync only when Trakt’s activity timestamps show a category has changed.
The caller must supply the authenticated EME owner. The service verifies that the profile’s stored Trakt link belongs to that owner.
Sourcepub async fn list_watchlist(
&self,
owner_id: UserId,
profile_id: MediaProfileId,
) -> Result<Vec<Value>, TraktSyncError>
pub async fn list_watchlist( &self, owner_id: UserId, profile_id: MediaProfileId, ) -> Result<Vec<Value>, TraktSyncError>
Read the linked Trakt account’s current watchlist without consulting or updating the local mirror.
Trakt is the source of truth for linked profiles. Returning provider data directly prevents stale local state from being presented as the account’s current watchlist.
Sourcepub async fn set_watchlist_item(
&self,
owner_id: UserId,
profile_id: MediaProfileId,
item: &MediaItem,
add: bool,
) -> Result<(), TraktSyncError>
pub async fn set_watchlist_item( &self, owner_id: UserId, profile_id: MediaProfileId, item: &MediaItem, add: bool, ) -> Result<(), TraktSyncError>
Add or remove a title from the linked Trakt account’s watchlist.
The provider is mutated directly; linked profiles do not maintain a separately writable local watchlist mirror. Repeating either operation is safe.
Sourcepub async fn mark_watched(
&self,
owner_id: UserId,
profile_id: MediaProfileId,
item: &MediaItem,
) -> Result<(), TraktSyncError>
pub async fn mark_watched( &self, owner_id: UserId, profile_id: MediaProfileId, item: &MediaItem, ) -> Result<(), TraktSyncError>
Mark a movie or show as watched in the linked Trakt account.
The remote write is performed first. The local history event is only recorded after Trakt confirms that it resolved the requested title.
Sourcepub async fn push_rating(
&self,
owner_id: UserId,
profile_id: MediaProfileId,
item: &MediaItem,
rating: &MediaRating,
) -> Result<(), TraktSyncError>
pub async fn push_rating( &self, owner_id: UserId, profile_id: MediaProfileId, item: &MediaItem, rating: &MediaRating, ) -> Result<(), TraktSyncError>
Write an EME rating through to Trakt, then persist its EME provenance.
EME’s 0..=5 scale maps linearly to Trakt’s integer 1..=10 scale: 0 maps to 1 and 5 maps to 10. Trakt’s coarser scale is necessarily quantized; inbound ratings use the inverse mapping.