I'm noticing that the models come with constructors like this:
|
impl Author { |
|
pub fn new(id: uuid::Uuid, name: AuthorName, email: EmailAddress) -> Self { |
|
Self { id, name, email } |
|
} |
Which is later used by the db implementation:
|
Ok(Author::new( |
|
author_id, |
|
req.name().clone(), |
|
req.email().clone(), |
|
)) |
But this means that consumers can construct potentially invalid Authors that aren't necessarily backed by the db.
Not sure if there's a good solution here, since you need to allow foreign modules to construct Author with the repository trait.
I'm noticing that the models come with constructors like this:
hexarch/src/lib/domain/blog/models/author.rs
Lines 14 to 17 in d58a5c6
Which is later used by the db implementation:
hexarch/src/lib/outbound/sqlite.rs
Lines 72 to 76 in d58a5c6
But this means that consumers can construct potentially invalid
Authors that aren't necessarily backed by the db.Not sure if there's a good solution here, since you need to allow foreign modules to construct
Authorwith the repository trait.