-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(dsp-meta): conversion of domain entities / values
- Loading branch information
Showing
32 changed files
with
245 additions
and
132 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use thiserror::Error; | ||
|
||
/// Type alias for `Result` with default error `DspDomainError`. | ||
/// | ||
/// Can be used like `std::result::Result` as well. | ||
pub type Result<T, E = DspDomainError> = std::result::Result<T, E>; | ||
|
||
/// This error is raised when a domain entity or value fails creation | ||
/// at runtime. | ||
#[derive(Debug, Error)] | ||
pub enum DspDomainError { | ||
#[error("Error creating value object: `{0}`")] | ||
CreateValueObject(String), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
pub mod error; | ||
pub mod metadata; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
use serde::Serialize; | ||
|
||
use crate::metadata::value::publication::Publication; | ||
|
||
#[derive(Clone, Debug, PartialEq, Serialize)] | ||
pub struct SimpleTextData(pub String); | ||
|
||
impl SimpleTextData { | ||
pub fn into_simple_text(self) -> Publication { | ||
Publication::SimpleText(self) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
use dsp_domain::metadata::entity::dataset::Dataset; | ||
use dsp_domain::metadata::value::Title; | ||
|
||
use crate::api::convert::hcl::hcl_block::HclBlock; | ||
use crate::error::DspMetaError; | ||
|
||
impl TryFrom<&hcl::Block> for Dataset { | ||
impl<'a> TryInto<Dataset> for HclBlock<'a> { | ||
type Error = DspMetaError; | ||
|
||
fn try_from(dataset_block: &hcl::Block) -> Result<Self, Self::Error> { | ||
if dataset_block.identifier.as_str() != "dataset" { | ||
fn try_into(self) -> Result<Dataset, Self::Error> { | ||
if self.0.identifier.as_str() != "dataset" { | ||
return Err(DspMetaError::ParseDataset( | ||
format!( | ||
"Parse error: dataset block needs to be named 'dataset', however got '{}' instead.", | ||
dataset_block.identifier.as_str() | ||
self.0.identifier.as_str() | ||
) | ||
.to_string(), | ||
.to_string(), | ||
)); | ||
} | ||
|
||
let title = Title(String::from("TODO: implement title extraction")); | ||
Ok(Self { title }) | ||
Ok(Dataset { title }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub struct HclAttribute<'a>(pub &'a hcl::Attribute); | ||
pub struct HclAttributes<'a>(pub Vec<&'a hcl::Attribute>); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub struct HclBody<'a>(pub &'a hcl::Block); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.