43 lines
1.2 KiB
Rust
43 lines
1.2 KiB
Rust
// file: ks-lib/tests/external_decoder_api.rs
|
|
// version: 2
|
|
|
|
//! Downstream-style compilation contract for externally implemented decoders.
|
|
|
|
struct ExternalDecoder;
|
|
|
|
impl ks_lib::DcApiProtocolDecoder for ExternalDecoder {
|
|
fn decoder_name(&self) -> &'static str {
|
|
return "external_decoder";
|
|
}
|
|
|
|
fn decoder_version(&self) -> &'static str {
|
|
return "1";
|
|
}
|
|
|
|
fn program_ids(&self) -> &'static [&'static str] {
|
|
return &[];
|
|
}
|
|
|
|
fn supports_observation(
|
|
&self,
|
|
_observation: &ks_lib::MdProgramObservation,
|
|
) -> ks_lib::DcApiDecoderSupport {
|
|
return ks_lib::DcApiDecoderSupport::No;
|
|
}
|
|
|
|
fn decode_observation(
|
|
&self,
|
|
_observation: &ks_lib::MdProgramObservation,
|
|
) -> ks_core::Result<std::vec::Vec<ks_lib::MdDecodedProtocolEvent>> {
|
|
return std::result::Result::Ok(std::vec::Vec::new());
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn external_decoder_uses_only_the_public_ks_lib_contract() {
|
|
let decoder: &dyn ks_lib::DcApiProtocolDecoder = &ExternalDecoder;
|
|
assert_eq!(decoder.decoder_name(), "external_decoder");
|
|
assert_eq!(decoder.decoder_version(), "1");
|
|
assert!(decoder.program_ids().is_empty());
|
|
}
|