//! Deprecated compatibility wrappers for caching endpoints. //! //! All writes and removals are now published immediately. Use [`CachingProd`](super::CachingProd) //! and [`CachingCons`](super::CachingCons) directly instead. These wrappers remain available; //! their removal is reserved for a future breaking release. //! //! Deferred publication could cause double drops if an endpoint was forgotten with [`core::mem::forget`]. //! Publication no longer depends on running its destructor. Code relying on delayed visibility or //! rollback must be updated even though the compatibility API remains available. //! //! # Migration //! //! Remove calls to `freeze`, `commit`, `fetch`, and `sync`. Endpoints publish their own changes //! immediately and fetch the opposite endpoint's progress as needed. `discard` is now a no-op: //! published items cannot be retracted. Stage items outside the ring buffer if rollback is needed, //! and use bulk operations such as `push_slice` and `pop_slice` to batch index updates. #![allow(deprecated)] use super::{caching::Caching, direct::Obs, traits::Wrap}; #[cfg(feature = "std")] use crate::traits::Consumer; use crate::{ rb::RbRef, traits::{ Based, consumer::{DelegateConsumer, impl_consumer_traits}, observer::DelegateObserver, producer::{DelegateProducer, Producer, impl_producer_traits}, }, }; /// Compatibility wrapper with the same immediate publication behavior as [`Caching`]. /// /// Unlike earlier versions, this wrapper never defers publication until `commit` or drop. #[deprecated(note = "use Caching directly; frozen endpoints now publish changes immediately and will be removed in the next breaking release")] pub struct Frozen { inner: Caching, } /// Deprecated producer wrapper. All inserted items are published immediately. #[deprecated(note = "use CachingProd; writes are now published immediately")] pub type FrozenProd = Frozen; /// Deprecated consumer wrapper. All removals are published immediately. #[deprecated(note = "use CachingCons; removals are now published immediately")] pub type FrozenCons = Frozen; impl Frozen { /// Create a compatibility wrapper with immediate publication. /// /// Panics if an endpoint with matching rights already exists. pub fn new(rb: R) -> Self { Self::from_caching(Caching::new(rb)) } pub(crate) fn from_caching(inner: Caching) -> Self { Self { inner } } /// Get ring buffer observer. pub fn observe(&self) -> Obs { self.inner.observe() } /// Does nothing: all changes have already been published. #[deprecated(note = "changes are published immediately; remove this call")] pub fn commit(&self) {} /// Refresh the cached opposite index. Operations also refresh it as needed. #[deprecated(note = "the caching endpoint fetches progress automatically; remove this call")] pub fn fetch(&self) { self.inner.fetch(); } /// Refresh the cached opposite index. All local changes are already published. #[deprecated(note = "changes are published immediately and progress is fetched automatically; remove this call")] pub fn sync(&self) { self.inner.fetch(); } } impl FrozenProd { /// Does nothing: inserted items are already published and cannot be retracted. /// /// Stage items outside the ring buffer if they may need to be discarded. #[deprecated( note = "discard is now a no-op because writes are immediately published; stage items outside the ring buffer to support rollback" )] pub fn discard(&mut self) {} } impl Based for Frozen { type Base = Caching; fn base(&self) -> &Self::Base { &self.inner } fn base_mut(&mut self) -> &mut Self::Base { &mut self.inner } } impl Wrap for Frozen { type RbRef = R; fn rb_ref(&self) -> &R { self.inner.rb_ref() } fn into_rb_ref(self) -> R { self.inner.into_rb_ref() } } impl AsRef for Frozen { fn as_ref(&self) -> &Self { self } } impl AsMut for Frozen { fn as_mut(&mut self) -> &mut Self { self } } impl DelegateObserver for Frozen {} impl DelegateProducer for FrozenProd {} impl DelegateConsumer for FrozenCons {} impl_producer_traits!(FrozenProd); impl_consumer_traits!(FrozenCons);