feat(domain): DiaryRepository::stream_user_history, DiaryExporter::stream_entries

This commit is contained in:
2026-06-12 01:05:32 +02:00
parent bf272bf8d9
commit ded7517a8a
3 changed files with 24 additions and 9 deletions

View File

@@ -144,6 +144,10 @@ pub trait DiaryRepository: Send + Sync {
) -> Result<Paginated<FeedEntry>, DomainError>; ) -> Result<Paginated<FeedEntry>, DomainError>;
async fn get_review_history(&self, movie_id: &MovieId) -> Result<ReviewHistory, DomainError>; async fn get_review_history(&self, movie_id: &MovieId) -> Result<ReviewHistory, DomainError>;
async fn get_user_history(&self, user_id: &UserId) -> Result<Vec<DiaryEntry>, DomainError>; async fn get_user_history(&self, user_id: &UserId) -> Result<Vec<DiaryEntry>, DomainError>;
fn stream_user_history(
&self,
user_id: UserId,
) -> futures::stream::BoxStream<'static, Result<DiaryEntry, DomainError>>;
async fn get_movie_stats(&self, movie_id: &MovieId) -> Result<MovieStats, DomainError>; async fn get_movie_stats(&self, movie_id: &MovieId) -> Result<MovieStats, DomainError>;
async fn get_movie_social_feed( async fn get_movie_social_feed(
&self, &self,
@@ -253,13 +257,12 @@ pub trait PasswordHasher: Send + Sync {
async fn verify(&self, plain_password: &str, hash: &PasswordHash) -> Result<bool, DomainError>; async fn verify(&self, plain_password: &str, hash: &PasswordHash) -> Result<bool, DomainError>;
} }
#[async_trait]
pub trait DiaryExporter: Send + Sync { pub trait DiaryExporter: Send + Sync {
async fn serialize_entries( fn stream_entries(
&self, &self,
entries: &[DiaryEntry], stream: futures::stream::BoxStream<'static, Result<DiaryEntry, DomainError>>,
format: ExportFormat, format: ExportFormat,
) -> Result<Vec<u8>, DomainError>; ) -> futures::stream::BoxStream<'static, Result<bytes::Bytes, DomainError>>;
} }
#[async_trait] #[async_trait]

View File

@@ -154,6 +154,13 @@ impl DiaryRepository for FakeDiaryRepository {
Ok(vec![]) Ok(vec![])
} }
fn stream_user_history(
&self,
_user_id: UserId,
) -> futures::stream::BoxStream<'static, Result<DiaryEntry, DomainError>> {
Box::pin(futures::stream::empty())
}
async fn get_movie_stats(&self, _movie_id: &MovieId) -> Result<MovieStats, DomainError> { async fn get_movie_stats(&self, _movie_id: &MovieId) -> Result<MovieStats, DomainError> {
Ok(MovieStats { Ok(MovieStats {
total_count: 0, total_count: 0,

View File

@@ -49,6 +49,12 @@ impl DiaryRepository for PanicDiaryRepository {
async fn get_user_history(&self, _: &UserId) -> Result<Vec<DiaryEntry>, DomainError> { async fn get_user_history(&self, _: &UserId) -> Result<Vec<DiaryEntry>, DomainError> {
panic!("PanicDiaryRepository called") panic!("PanicDiaryRepository called")
} }
fn stream_user_history(
&self,
_: UserId,
) -> futures::stream::BoxStream<'static, Result<DiaryEntry, DomainError>> {
panic!("PanicDiaryRepository called")
}
async fn get_movie_stats(&self, _: &MovieId) -> Result<MovieStats, DomainError> { async fn get_movie_stats(&self, _: &MovieId) -> Result<MovieStats, DomainError> {
panic!("PanicDiaryRepository called") panic!("PanicDiaryRepository called")
} }
@@ -250,13 +256,12 @@ impl PosterFetcherClient for PanicPosterFetcher {
pub struct PanicDiaryExporter; pub struct PanicDiaryExporter;
#[async_trait]
impl DiaryExporter for PanicDiaryExporter { impl DiaryExporter for PanicDiaryExporter {
async fn serialize_entries( fn stream_entries(
&self, &self,
_: &[DiaryEntry], _stream: futures::stream::BoxStream<'static, Result<DiaryEntry, DomainError>>,
_: ExportFormat, _format: ExportFormat,
) -> Result<Vec<u8>, DomainError> { ) -> futures::stream::BoxStream<'static, Result<bytes::Bytes, DomainError>> {
panic!("PanicDiaryExporter called") panic!("PanicDiaryExporter called")
} }
} }