Trait Dummy

Source
pub trait Dummy: Sized {
    // Required method
    fn dummy() -> Self;
}
Expand description

A trait for giving a type a dummy value.

Sometimes in tests you need to provide a value for a type, but the actual value doesn’t matter. This trait allows defining a “dummy” value for a type, separated from an eventual default value, that can be reused across multiple tests.

Note: should not be confused with “fake” values, fake values aim to be believable and contain valid cryptography (if they have some), dummies don’t aim for those characteristics.

§Example

use mithril_common::test::double::Dummy;

struct MyType(String);

impl Dummy for MyType {
    fn dummy() -> Self {
        MyType("whatever".to_string())
    }
}

let instance = MyType::dummy();

Required Methods§

Source

fn dummy() -> Self

Return a dummy value for the type

Useful for test contexts when the actual value doesn’t matter.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Dummy for SignedEntityType

Source§

impl Dummy for SupportedEra

Source§

impl Dummy for CardanoTransactionsSetProof

Source§

impl Dummy for CardanoTransactionsSigningConfig

Source§

impl Dummy for ChainPoint

Source§

impl Dummy for SignedEntityConfig

Source§

impl Dummy for TimePoint

Source§

impl Dummy for AggregatorFeaturesMessage

Source§

impl Dummy for CardanoDatabaseDigestListItemMessage

Source§

impl Dummy for CardanoDatabaseImmutableFilesRestoredMessage

Source§

impl Dummy for CardanoDatabaseSnapshotListItemMessage

Source§

impl Dummy for CardanoDatabaseSnapshotMessage

Source§

impl Dummy for CardanoStakeDistributionListItemMessage

Source§

impl Dummy for CardanoStakeDistributionMessage

Source§

impl Dummy for CardanoTransactionSnapshotListItemMessage

Source§

impl Dummy for CardanoTransactionSnapshotMessage

Source§

impl Dummy for CardanoTransactionsSetProofMessagePart

Source§

impl Dummy for CertificateListItemMessage

Source§

impl Dummy for CertificateMessage

Source§

impl Dummy for CertificateMetadataMessagePart

Source§

impl Dummy for EpochSettingsMessage

Source§

impl Dummy for MithrilStakeDistributionListItemMessage

Source§

impl Dummy for MithrilStakeDistributionMessage

Source§

impl Dummy for RegisterSignatureMessageDmq

Source§

impl Dummy for RegisterSignatureMessageHttp

Source§

impl Dummy for RegisterSignerMessage

Source§

impl Dummy for SignerMessagePart

Source§

impl Dummy for SignerWithStakeMessagePart

Source§

impl Dummy for SnapshotDownloadMessage

Source§

impl Dummy for SnapshotListItemMessage

Source§

impl Dummy for SnapshotMessage

Source§

impl Dummy for SignedEntity<CardanoStakeDistribution>

Source§

impl Dummy for SignedEntity<CardanoTransactionsSnapshot>

Source§

impl Dummy for SignedEntity<MithrilStakeDistribution>

Source§

impl Dummy for SignedEntity<Snapshot>