indexbus_kit/runtime/
tier_a.rs1use crate::errors::{Error, Result};
2
3use indexbus_adapters_core::{Backoff, TryRecvBytes};
4
5pub struct CoreSpscRx(pub indexbus_core::SpscReceiver);
9
10impl TryRecvBytes for CoreSpscRx {
11 fn try_recv_into(
12 &mut self,
13 out: &mut [u8],
14 ) -> core::result::Result<Option<usize>, indexbus_adapters_core::TryRecvError> {
15 self.0
16 .try_recv_into(out)
17 .map_err(|_| indexbus_adapters_core::TryRecvError::Other)
18 }
19}
20
21pub fn recv_into_tier_a<'a, B: Backoff>(
25 rx: indexbus_core::SpscReceiver,
26 out: &'a mut [u8],
27 backoff: B,
28) -> indexbus_adapters::tier_a::RecvIntoTierA<'a, CoreSpscRx, B> {
29 indexbus_adapters::tier_a::RecvIntoTierA::new(CoreSpscRx(rx), out, backoff)
30}
31
32pub fn map_err(e: impl core::fmt::Debug) -> Error {
34 Error::msg(format!("{e:?}"))
35}
36
37pub fn ok<T>(v: T) -> Result<T> {
39 Ok(v)
40}