pub struct Abstract(/* private fields */);Expand description
The abstract netidx value type
Any type implementing Any + Pack + Send + Sync can be wrapped in an Abstract and published to netidx.
When a client reads an abstract value from netidx, it will look to see if it has the same type registered (by UUID). If it does, it will be able to decode the abstract type and use it. If it does not, then a special type called UnknownAbstractType will be substituted and the decode will not fail.
You may recover the original type by downcasting, which will fail if the type isn’t the one you expected.
Through abstract types the Value type can be extended in whatever way is suited by the application/user site without every netidx user needing to agree on a new protocol extension. As long as all the applications using an abstract type register it with the same UUID, and the Pack implementation remains compatible, then it can be seamlessly used without interfering with non participarting applications.
Implementations§
Source§impl Abstract
impl Abstract
Sourcepub fn downcast_ref<T: Any + Send + Sync>(&self) -> Option<&T>
pub fn downcast_ref<T: Any + Send + Sync>(&self) -> Option<&T>
Downcast &self to &T. If self isn’t a T then return None.
Sourcepub fn register<T: Any + Debug + Pack + Hash + Eq + Ord + Send + Sync>(
id: Uuid,
) -> Result<AbstractWrapper<T>>
pub fn register<T: Any + Debug + Pack + Hash + Eq + Ord + Send + Sync>( id: Uuid, ) -> Result<AbstractWrapper<T>>
Register a new abstract type, return an object that will wrap instances of T as an Abstract.
Register is idempotent.
- it is an error to register T with multiple different ids
- it is an error to register the same id with multiple Ts
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Abstract
impl<'de> Deserialize<'de> for Abstract
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl Ord for Abstract
impl Ord for Abstract
Source§impl Pack for Abstract
impl Pack for Abstract
fn encoded_len(&self) -> usize
fn encode(&self, buf: &mut impl BufMut) -> Result<(), PackError>
fn decode(buf: &mut impl Buf) -> Result<Self, PackError>
fn const_encoded_len() -> Option<usize>
fn decode_into(&mut self, buf: &mut impl Buf) -> Result<(), PackError>where
Self: Sized,
Source§impl PartialOrd for Abstract
impl PartialOrd for Abstract
impl Eq for Abstract
Auto Trait Implementations§
impl Freeze for Abstract
impl !RefUnwindSafe for Abstract
impl Send for Abstract
impl Sync for Abstract
impl Unpin for Abstract
impl !UnwindSafe for Abstract
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.