pub struct MockDecoder {
pub state: RwLock<MockDecoderState>,
pub decode_delay: Mutex<Option<Duration>>,
/* private fields */
}Expand description
A mock decoder that records all operations for testing.
Fields§
§state: RwLock<MockDecoderState>§decode_delay: Mutex<Option<Duration>>Optional delay to simulate decoder latency (applied per decode call).
Implementations§
Source§impl MockDecoder
impl MockDecoder
pub fn new() -> Self
pub fn with_features(features: DecoderFeatures) -> Self
pub fn supported_features(&self) -> DecoderFeatures
Sourcepub fn from_config(config: Value) -> Self
pub fn from_config(config: Value) -> Self
Create a MockDecoder from a JSON config value (for CLI use).
Sourcepub async fn set_response(&self, syndrome_data: Vec<u8>, subgraph: Vec<u64>)
pub async fn set_response(&self, syndrome_data: Vec<u8>, subgraph: Vec<u64>)
Set a custom response for a specific syndrome
Sourcepub fn set_decode_delay(&self, delay: Duration)
pub fn set_decode_delay(&self, delay: Duration)
Set the decode delay for simulating decoder latency.
Sourcepub fn block_next_decode(&self) -> Arc<MockDecoderDecodeBlocker> ⓘ
pub fn block_next_decode(&self) -> Arc<MockDecoderDecodeBlocker> ⓘ
Block the next decode call until the returned notifier receives a permit.
Trait Implementations§
Source§impl BlackBoxDecoder for MockDecoder
impl BlackBoxDecoder for MockDecoder
Source§fn get_capabilities<'life0, 'async_trait>(
&'life0 self,
_request: Request<()>,
) -> Pin<Box<dyn Future<Output = Result<Response<DecoderCapabilities>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_capabilities<'life0, 'async_trait>(
&'life0 self,
_request: Request<()>,
) -> Pin<Box<dyn Future<Output = Result<Response<DecoderCapabilities>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Report optional decoder features. Advertising multiple features means
they may be used together.
Source§fn decode<'life0, 'async_trait>(
&'life0 self,
request: Request<DecodingProblem>,
) -> Pin<Box<dyn Future<Output = Result<Response<ParityFactor>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn decode<'life0, 'async_trait>(
&'life0 self,
request: Request<DecodingProblem>,
) -> Pin<Box<dyn Future<Output = Result<Response<ParityFactor>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
calling this service is in general inefficient because it has to process
the entire decoding hypergraph during runtime. Consider using preloaded
decoder instances like the rpc interfaces followed
Source§fn load_hypergraph<'life0, 'async_trait>(
&'life0 self,
request: Request<DecodingHypergraph>,
) -> Pin<Box<dyn Future<Output = Result<Response<LoadHypergraphResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn load_hypergraph<'life0, 'async_trait>(
&'life0 self,
request: Request<DecodingHypergraph>,
) -> Pin<Box<dyn Future<Output = Result<Response<LoadHypergraphResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
load a decoding hypergraph into the decoder service so that the runtime
decoding can simply decode using the existing instances
Source§fn decode_loaded<'life0, 'async_trait>(
&'life0 self,
request: Request<LoadedDecodingProblem>,
) -> Pin<Box<dyn Future<Output = Result<Response<ParityFactor>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn decode_loaded<'life0, 'async_trait>(
&'life0 self,
request: Request<LoadedDecodingProblem>,
) -> Pin<Box<dyn Future<Output = Result<Response<ParityFactor>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
decode using a preloaded hypergraph instance
Source§impl Debug for MockDecoder
impl Debug for MockDecoder
Auto Trait Implementations§
impl !Freeze for MockDecoder
impl !RefUnwindSafe for MockDecoder
impl !UnwindSafe for MockDecoder
impl Forget for MockDecoder
impl Move for MockDecoder
impl Send for MockDecoder
impl Sync for MockDecoder
impl Unpin for MockDecoder
impl UnsafeUnpin for MockDecoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request