use crate::enums::MeasurementUnit;
use crate::HostTypes;
pub trait CarryChain<H: HostTypes> {
fn chain_length(&self) -> u64;
fn generate_mask(&self) -> u64;
fn propagate_mask(&self) -> u64;
fn kill_mask(&self) -> u64;
}
pub trait CarryEvent<H: HostTypes> {
fn event_kind(&self) -> u64;
fn site_position(&self) -> u64;
}
pub trait CarryProfile<H: HostTypes> {
fn carry_count(&self) -> u64;
fn max_propagation_length(&self) -> u64;
type CarryChain: CarryChain<H>;
fn profile_chain(&self) -> &Self::CarryChain;
}
pub trait EncodingConfiguration<H: HostTypes> {
fn symbol_set_size(&self) -> u64;
fn quantization_bits(&self) -> u64;
type TermExpression: crate::kernel::schema::TermExpression<H>;
fn encoding_map(&self) -> &Self::TermExpression;
}
pub trait EncodingQuality<H: HostTypes> {
fn mean_delta(&self) -> H::Decimal;
fn discrimination_ratio(&self) -> H::Decimal;
fn is_optimal_encoding(&self) -> bool;
}
pub trait CarryDepthObservable<H: HostTypes>: crate::bridge::observable::Observable<H> {}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullCarryChain<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullCarryChain<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullCarryChain<H> {
pub const ABSENT: NullCarryChain<H> = NullCarryChain {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> CarryChain<H> for NullCarryChain<H> {
fn chain_length(&self) -> u64 {
0
}
fn generate_mask(&self) -> u64 {
0
}
fn propagate_mask(&self) -> u64 {
0
}
fn kill_mask(&self) -> u64 {
0
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullCarryEvent<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullCarryEvent<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullCarryEvent<H> {
pub const ABSENT: NullCarryEvent<H> = NullCarryEvent {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> CarryEvent<H> for NullCarryEvent<H> {
fn event_kind(&self) -> u64 {
0
}
fn site_position(&self) -> u64 {
0
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullCarryProfile<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullCarryProfile<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullCarryProfile<H> {
pub const ABSENT: NullCarryProfile<H> = NullCarryProfile {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> CarryProfile<H> for NullCarryProfile<H> {
fn carry_count(&self) -> u64 {
0
}
fn max_propagation_length(&self) -> u64 {
0
}
type CarryChain = NullCarryChain<H>;
fn profile_chain(&self) -> &Self::CarryChain {
&<NullCarryChain<H>>::ABSENT
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullEncodingConfiguration<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullEncodingConfiguration<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullEncodingConfiguration<H> {
pub const ABSENT: NullEncodingConfiguration<H> = NullEncodingConfiguration {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> EncodingConfiguration<H> for NullEncodingConfiguration<H> {
fn symbol_set_size(&self) -> u64 {
0
}
fn quantization_bits(&self) -> u64 {
0
}
type TermExpression = crate::kernel::schema::NullTermExpression<H>;
fn encoding_map(&self) -> &Self::TermExpression {
&<crate::kernel::schema::NullTermExpression<H>>::ABSENT
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullEncodingQuality<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullEncodingQuality<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullEncodingQuality<H> {
pub const ABSENT: NullEncodingQuality<H> = NullEncodingQuality {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> EncodingQuality<H> for NullEncodingQuality<H> {
fn mean_delta(&self) -> H::Decimal {
H::EMPTY_DECIMAL
}
fn discrimination_ratio(&self) -> H::Decimal {
H::EMPTY_DECIMAL
}
fn is_optimal_encoding(&self) -> bool {
false
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct NullCarryDepthObservable<H: HostTypes> {
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Default for NullCarryDepthObservable<H> {
fn default() -> Self {
Self {
_phantom: core::marker::PhantomData,
}
}
}
impl<H: HostTypes> NullCarryDepthObservable<H> {
pub const ABSENT: NullCarryDepthObservable<H> = NullCarryDepthObservable {
_phantom: core::marker::PhantomData,
};
}
impl<H: HostTypes> crate::bridge::observable::Observable<H> for NullCarryDepthObservable<H> {
fn value(&self) -> H::Decimal {
H::EMPTY_DECIMAL
}
fn source(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
fn target(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
fn has_unit(&self) -> MeasurementUnit {
<MeasurementUnit>::default()
}
}
impl<H: HostTypes> CarryDepthObservable<H> for NullCarryDepthObservable<H> {}
#[derive(Debug)]
pub struct CarryChainHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for CarryChainHandle<H> {}
impl<H: HostTypes> Clone for CarryChainHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for CarryChainHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for CarryChainHandle<H> {}
impl<H: HostTypes> core::hash::Hash for CarryChainHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> CarryChainHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait CarryChainResolver<H: HostTypes> {
fn resolve(&self, handle: CarryChainHandle<H>) -> Option<CarryChainRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct CarryChainRecord<H: HostTypes> {
pub chain_length: u64,
pub generate_mask: u64,
pub propagate_mask: u64,
pub kill_mask: u64,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedCarryChain<'r, R: CarryChainResolver<H>, H: HostTypes> {
handle: CarryChainHandle<H>,
resolver: &'r R,
record: Option<CarryChainRecord<H>>,
}
impl<'r, R: CarryChainResolver<H>, H: HostTypes> ResolvedCarryChain<'r, R, H> {
#[inline]
pub fn new(handle: CarryChainHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> CarryChainHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&CarryChainRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: CarryChainResolver<H>, H: HostTypes> CarryChain<H> for ResolvedCarryChain<'r, R, H> {
fn chain_length(&self) -> u64 {
match &self.record {
Some(r) => r.chain_length,
None => 0,
}
}
fn generate_mask(&self) -> u64 {
match &self.record {
Some(r) => r.generate_mask,
None => 0,
}
}
fn propagate_mask(&self) -> u64 {
match &self.record {
Some(r) => r.propagate_mask,
None => 0,
}
}
fn kill_mask(&self) -> u64 {
match &self.record {
Some(r) => r.kill_mask,
None => 0,
}
}
}
#[derive(Debug)]
pub struct CarryEventHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for CarryEventHandle<H> {}
impl<H: HostTypes> Clone for CarryEventHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for CarryEventHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for CarryEventHandle<H> {}
impl<H: HostTypes> core::hash::Hash for CarryEventHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> CarryEventHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait CarryEventResolver<H: HostTypes> {
fn resolve(&self, handle: CarryEventHandle<H>) -> Option<CarryEventRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct CarryEventRecord<H: HostTypes> {
pub event_kind: u64,
pub site_position: u64,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedCarryEvent<'r, R: CarryEventResolver<H>, H: HostTypes> {
handle: CarryEventHandle<H>,
resolver: &'r R,
record: Option<CarryEventRecord<H>>,
}
impl<'r, R: CarryEventResolver<H>, H: HostTypes> ResolvedCarryEvent<'r, R, H> {
#[inline]
pub fn new(handle: CarryEventHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> CarryEventHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&CarryEventRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: CarryEventResolver<H>, H: HostTypes> CarryEvent<H> for ResolvedCarryEvent<'r, R, H> {
fn event_kind(&self) -> u64 {
match &self.record {
Some(r) => r.event_kind,
None => 0,
}
}
fn site_position(&self) -> u64 {
match &self.record {
Some(r) => r.site_position,
None => 0,
}
}
}
#[derive(Debug)]
pub struct CarryProfileHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for CarryProfileHandle<H> {}
impl<H: HostTypes> Clone for CarryProfileHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for CarryProfileHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for CarryProfileHandle<H> {}
impl<H: HostTypes> core::hash::Hash for CarryProfileHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> CarryProfileHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait CarryProfileResolver<H: HostTypes> {
fn resolve(&self, handle: CarryProfileHandle<H>) -> Option<CarryProfileRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct CarryProfileRecord<H: HostTypes> {
pub carry_count: u64,
pub max_propagation_length: u64,
pub profile_chain_handle: CarryChainHandle<H>,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedCarryProfile<'r, R: CarryProfileResolver<H>, H: HostTypes> {
handle: CarryProfileHandle<H>,
resolver: &'r R,
record: Option<CarryProfileRecord<H>>,
}
impl<'r, R: CarryProfileResolver<H>, H: HostTypes> ResolvedCarryProfile<'r, R, H> {
#[inline]
pub fn new(handle: CarryProfileHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> CarryProfileHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&CarryProfileRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: CarryProfileResolver<H>, H: HostTypes> CarryProfile<H>
for ResolvedCarryProfile<'r, R, H>
{
fn carry_count(&self) -> u64 {
match &self.record {
Some(r) => r.carry_count,
None => 0,
}
}
fn max_propagation_length(&self) -> u64 {
match &self.record {
Some(r) => r.max_propagation_length,
None => 0,
}
}
type CarryChain = NullCarryChain<H>;
fn profile_chain(&self) -> &Self::CarryChain {
&<NullCarryChain<H>>::ABSENT
}
}
impl<'r, R: CarryProfileResolver<H>, H: HostTypes> ResolvedCarryProfile<'r, R, H> {
#[inline]
pub fn resolve_profile_chain<'r2, R2: CarryChainResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<ResolvedCarryChain<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(ResolvedCarryChain::new(record.profile_chain_handle, r))
}
}
#[derive(Debug)]
pub struct EncodingConfigurationHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for EncodingConfigurationHandle<H> {}
impl<H: HostTypes> Clone for EncodingConfigurationHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for EncodingConfigurationHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for EncodingConfigurationHandle<H> {}
impl<H: HostTypes> core::hash::Hash for EncodingConfigurationHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> EncodingConfigurationHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait EncodingConfigurationResolver<H: HostTypes> {
fn resolve(
&self,
handle: EncodingConfigurationHandle<H>,
) -> Option<EncodingConfigurationRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct EncodingConfigurationRecord<H: HostTypes> {
pub symbol_set_size: u64,
pub quantization_bits: u64,
pub encoding_map_handle: crate::kernel::schema::TermExpressionHandle<H>,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedEncodingConfiguration<'r, R: EncodingConfigurationResolver<H>, H: HostTypes> {
handle: EncodingConfigurationHandle<H>,
resolver: &'r R,
record: Option<EncodingConfigurationRecord<H>>,
}
impl<'r, R: EncodingConfigurationResolver<H>, H: HostTypes>
ResolvedEncodingConfiguration<'r, R, H>
{
#[inline]
pub fn new(handle: EncodingConfigurationHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> EncodingConfigurationHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&EncodingConfigurationRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: EncodingConfigurationResolver<H>, H: HostTypes> EncodingConfiguration<H>
for ResolvedEncodingConfiguration<'r, R, H>
{
fn symbol_set_size(&self) -> u64 {
match &self.record {
Some(r) => r.symbol_set_size,
None => 0,
}
}
fn quantization_bits(&self) -> u64 {
match &self.record {
Some(r) => r.quantization_bits,
None => 0,
}
}
type TermExpression = crate::kernel::schema::NullTermExpression<H>;
fn encoding_map(&self) -> &Self::TermExpression {
&<crate::kernel::schema::NullTermExpression<H>>::ABSENT
}
}
impl<'r, R: EncodingConfigurationResolver<H>, H: HostTypes>
ResolvedEncodingConfiguration<'r, R, H>
{
#[inline]
pub fn resolve_encoding_map<'r2, R2: crate::kernel::schema::TermExpressionResolver<H>>(
&self,
r: &'r2 R2,
) -> Option<crate::kernel::schema::ResolvedTermExpression<'r2, R2, H>> {
let record = self.record.as_ref()?;
Some(crate::kernel::schema::ResolvedTermExpression::new(
record.encoding_map_handle,
r,
))
}
}
#[derive(Debug)]
pub struct EncodingQualityHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for EncodingQualityHandle<H> {}
impl<H: HostTypes> Clone for EncodingQualityHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for EncodingQualityHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for EncodingQualityHandle<H> {}
impl<H: HostTypes> core::hash::Hash for EncodingQualityHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> EncodingQualityHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait EncodingQualityResolver<H: HostTypes> {
fn resolve(&self, handle: EncodingQualityHandle<H>) -> Option<EncodingQualityRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct EncodingQualityRecord<H: HostTypes> {
pub mean_delta: H::Decimal,
pub discrimination_ratio: H::Decimal,
pub is_optimal_encoding: bool,
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedEncodingQuality<'r, R: EncodingQualityResolver<H>, H: HostTypes> {
handle: EncodingQualityHandle<H>,
resolver: &'r R,
record: Option<EncodingQualityRecord<H>>,
}
impl<'r, R: EncodingQualityResolver<H>, H: HostTypes> ResolvedEncodingQuality<'r, R, H> {
#[inline]
pub fn new(handle: EncodingQualityHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> EncodingQualityHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&EncodingQualityRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: EncodingQualityResolver<H>, H: HostTypes> EncodingQuality<H>
for ResolvedEncodingQuality<'r, R, H>
{
fn mean_delta(&self) -> H::Decimal {
match &self.record {
Some(r) => r.mean_delta,
None => H::EMPTY_DECIMAL,
}
}
fn discrimination_ratio(&self) -> H::Decimal {
match &self.record {
Some(r) => r.discrimination_ratio,
None => H::EMPTY_DECIMAL,
}
}
fn is_optimal_encoding(&self) -> bool {
match &self.record {
Some(r) => r.is_optimal_encoding,
None => false,
}
}
}
#[derive(Debug)]
pub struct CarryDepthObservableHandle<H: HostTypes> {
pub fingerprint: crate::enforcement::ContentFingerprint,
_phantom: core::marker::PhantomData<H>,
}
impl<H: HostTypes> Copy for CarryDepthObservableHandle<H> {}
impl<H: HostTypes> Clone for CarryDepthObservableHandle<H> {
#[inline]
fn clone(&self) -> Self {
*self
}
}
impl<H: HostTypes> PartialEq for CarryDepthObservableHandle<H> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.fingerprint == other.fingerprint
}
}
impl<H: HostTypes> Eq for CarryDepthObservableHandle<H> {}
impl<H: HostTypes> core::hash::Hash for CarryDepthObservableHandle<H> {
#[inline]
fn hash<S: core::hash::Hasher>(&self, state: &mut S) {
self.fingerprint.hash(state);
}
}
impl<H: HostTypes> CarryDepthObservableHandle<H> {
#[inline]
#[must_use]
pub const fn new(fingerprint: crate::enforcement::ContentFingerprint) -> Self {
Self {
fingerprint,
_phantom: core::marker::PhantomData,
}
}
}
pub trait CarryDepthObservableResolver<H: HostTypes> {
fn resolve(
&self,
handle: CarryDepthObservableHandle<H>,
) -> Option<CarryDepthObservableRecord<H>>;
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct CarryDepthObservableRecord<H: HostTypes> {
#[doc(hidden)]
pub _phantom: core::marker::PhantomData<H>,
}
pub struct ResolvedCarryDepthObservable<'r, R: CarryDepthObservableResolver<H>, H: HostTypes> {
handle: CarryDepthObservableHandle<H>,
resolver: &'r R,
record: Option<CarryDepthObservableRecord<H>>,
}
impl<'r, R: CarryDepthObservableResolver<H>, H: HostTypes> ResolvedCarryDepthObservable<'r, R, H> {
#[inline]
pub fn new(handle: CarryDepthObservableHandle<H>, resolver: &'r R) -> Self {
let record = resolver.resolve(handle);
Self {
handle,
resolver,
record,
}
}
#[inline]
#[must_use]
pub const fn handle(&self) -> CarryDepthObservableHandle<H> {
self.handle
}
#[inline]
#[must_use]
pub const fn resolver(&self) -> &'r R {
self.resolver
}
#[inline]
#[must_use]
pub const fn record(&self) -> Option<&CarryDepthObservableRecord<H>> {
self.record.as_ref()
}
}
impl<'r, R: CarryDepthObservableResolver<H>, H: HostTypes> crate::bridge::observable::Observable<H>
for ResolvedCarryDepthObservable<'r, R, H>
{
fn value(&self) -> H::Decimal {
H::EMPTY_DECIMAL
}
fn source(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
fn target(&self) -> &H::HostString {
H::EMPTY_HOST_STRING
}
fn has_unit(&self) -> MeasurementUnit {
<MeasurementUnit>::default()
}
}
impl<'r, R: CarryDepthObservableResolver<H>, H: HostTypes> CarryDepthObservable<H>
for ResolvedCarryDepthObservable<'r, R, H>
{
}