Skip to content

Commit 2570d1d

Browse files
committed
Update Artifact trait
1 parent 538e2e2 commit 2570d1d

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

mithril-aggregator/src/artifact_builder/dummy_artifact.rs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::marker::PhantomData;
2-
31
use async_trait::async_trait;
42
use mithril_common::{
53
entities::Certificate,
@@ -12,24 +10,19 @@ use crate::artifact_builder::ArtifactBuilder;
1210

1311
/// Dummy artifact
1412
#[derive(Serialize, Deserialize, PartialEq, Debug)]
15-
pub struct DummyArtifact<'a> {
13+
pub struct DummyArtifact {
1614
message: String,
1715
beacon: DummyBeacon,
18-
phantom: PhantomData<&'a DummyBeacon>,
1916
}
2017

21-
impl<'a> DummyArtifact<'a> {
18+
impl DummyArtifact {
2219
/// Dummy artifact factory
2320
pub fn new(message: String, beacon: DummyBeacon) -> Self {
24-
Self {
25-
message,
26-
beacon,
27-
phantom: PhantomData,
28-
}
21+
Self { message, beacon }
2922
}
3023
}
3124

32-
impl<'a> Artifact<'a> for DummyArtifact<'a> {}
25+
impl Artifact for DummyArtifact {}
3326

3427
/// A [DummyArtifact] builder
3528
pub struct DummyArtifactBuilder {}
@@ -48,9 +41,9 @@ impl Default for DummyArtifactBuilder {
4841
}
4942

5043
#[async_trait]
51-
impl<'a> ArtifactBuilder<'a, DummyBeacon, DummyArtifact<'a>> for DummyArtifactBuilder {
44+
impl ArtifactBuilder<DummyBeacon, DummyArtifact> for DummyArtifactBuilder {
5245
async fn compute_artifact(
53-
&'a self,
46+
&self,
5447
beacon: DummyBeacon,
5548
certificate: &Certificate,
5649
) -> StdResult<DummyArtifact> {

mithril-aggregator/src/artifact_builder/interface.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ use mithril_common::{
55
StdResult,
66
};
77

8+
#[cfg(test)]
9+
use mockall::automock;
10+
811
/// ArtifactBuilder is trait for building an artifact
12+
#[cfg_attr(test, automock)]
913
#[async_trait]
10-
pub trait ArtifactBuilder<'a, U, W>
14+
pub trait ArtifactBuilder<U, W>: Send + Sync
1115
where
1216
U: Beacon,
13-
W: Artifact<'a>,
17+
W: Artifact,
1418
{
1519
/// Compute an artifact
16-
async fn compute_artifact(&'a self, beacon: U, certificate: &Certificate) -> StdResult<W>;
20+
async fn compute_artifact(&self, beacon: U, certificate: &Certificate) -> StdResult<W>;
1721
}

mithril-common/src/signable_builder/interface.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use async_trait::async_trait;
2-
use serde::{Deserialize, Serialize};
2+
use serde::{de::DeserializeOwned, Serialize};
33
use std::fmt::Debug;
44

55
use crate::{entities::ProtocolMessage, StdResult};
@@ -14,7 +14,7 @@ pub trait Signable: Send + Sync {
1414
}
1515

1616
/// Artifact is a trait for types that represent signed artifacts
17-
pub trait Artifact<'a>: Serialize + Deserialize<'a> + PartialEq + Debug {}
17+
pub trait Artifact: Serialize + DeserializeOwned + PartialEq + Debug + Send + Sync {}
1818

1919
/// SignableBuilder is trait for building a signable for a beacon
2020
#[async_trait]

0 commit comments

Comments
 (0)