use alloc::boxed::Box;
use core::hint::unreachable_unchecked;
use alloc::collections::{BTreeMap, BTreeSet,
LinkedList, VecDeque};
use alloc::rc::Rc;
use alloc::string::{String, ToString};
use alloc::sync::Arc;
use alloc::vec::Vec;
use crate::AXIOM_OFFSET;
use crate::const_daemonic_hash;
use crate::daemonic::TopologySegment;
use crate::Temporal;
use crate::Annotation;
use crate::Observation;
use crate::{DaemonicError};
use crate::daemonic::glass::daemonic::{Daemonic, GlassError};
use crate::daemonic::glass::daemonic::glass::GlassContainers::GlassVec;
use crate::daemonic::glass::daemonic::GlassError::Containers;
use crate::daemonic::glass::daemonic_system_call::DaemonicSystemCall;
use crate::daemonic::glass::error::daemonic::glass::GlassContainers;
use crate::daemonic::TopologyAnchor;
use super::{Glass, Severity, ObservationTier, Error};
use super::states::{GlassStable, GlassCracked, GlassFracture, GlassUnknown, GlassShattered};
macro_rules! impl_glass_primitive {
($($anchor:ident, $upper:ident = $ty:ident),* $(,)?) => {
$(
pub(crate) static $anchor: TopologySegment = TopologySegment {
label: concat!("Daemonic::Glass::Primitives::", stringify!($ty)),
hash: const_daemonic_hash(
concat!("Daemonic::Glass::Primitives::", stringify!($ty)).as_bytes(),
AXIOM_OFFSET,
),
crypto_id: const_daemonic_hash(
concat!("Daemonic::Glass::Primitives::", stringify!($ty)).as_bytes(),
TOPOLOGY_ANCHOR,
),
depth: 3u16,
};
#[allow(unsafe_code)]
unsafe impl DaemonicSystemCall for $ty {}
impl Glass<$ty> for $ty {
type Anchor = TopologySegment;
fn position(&self) -> &TopologySegment { &$anchor }
fn severity(&self) -> Severity { Severity::Stable }
fn tier(&self) -> ObservationTier { ObservationTier::Primitive }
fn payload(&self) -> Option<&$ty> { Some(self) }
fn into_payload(self) -> Option<$ty> { Some(self) }
}
impl GlassStable<$ty> for $ty {
fn value(&self) -> Observation<&$ty> {
Observation {
position: &$anchor,
severity: Severity::Stable,
tier: ObservationTier::Primitive,
annotation: Annotation::None,
temporal: Temporal::Current,
payload: self.payload(),
}
}
fn into_value(self) -> Observation<$ty> {
Observation {
position: &$anchor,
severity: Severity::Stable,
tier: ObservationTier::Primitive,
annotation: Annotation::None,
temporal: Temporal::Current,
payload: self.into_payload(),
}
}
}
)*
};
}
impl_glass_primitive!(
U8_TOPOLOGY_ANCHOR, U8 = u8,
U16_TOPOLOGY_ANCHOR, U16 = u16,
U32_TOPOLOGY_ANCHOR, U32 = u32,
U64_TOPOLOGY_ANCHOR, U64 = u64,
U128_TOPOLOGY_ANCHOR, U128 = u128,
USIZE_TOPOLOGY_ANCHOR, USIZE = usize,
I8_TOPOLOGY_ANCHOR, I8 = i8,
I16_TOPOLOGY_ANCHOR, I16 = i16,
I32_TOPOLOGY_ANCHOR, I32 = i32,
I64_TOPOLOGY_ANCHOR, I64 = i64,
I128_TOPOLOGY_ANCHOR, I128 = i128,
ISIZE_TOPOLOGY_ANCHOR, ISIZE = isize,
F32_TOPOLOGY_ANCHOR, F32 = f32,
F64_TOPOLOGY_ANCHOR, F64 = f64,
BOOL_TOPOLOGY_ANCHOR, BOOL = bool,
CHAR_TOPOLOGY_ANCHOR, CHAR = char,
);
static PARENTHETICAL_ENCLOSURE_TOPOLOGY_ANCH0R: TopologySegment = TopologySegment {
label: "Daemonic::Glass::Primitives::()",
hash: const_daemonic_hash(
"Daemonic::Glass::Primitives::()".as_bytes(),
AXIOM_OFFSET,
),
crypto_id: const_daemonic_hash("Daemonic::Glass::Primitives::()".as_bytes(), TOPOLOGY_ANCHOR),
depth: 3u16,
};
use crate::TOPOLOGY_ANCHOR;
#[allow(unsafe_code)]
unsafe impl DaemonicSystemCall for () {}
impl Glass<()> for () {
type Anchor = TopologySegment;
fn position(&self) -> &TopologySegment { &PARENTHETICAL_ENCLOSURE_TOPOLOGY_ANCH0R }
fn severity(&self) -> Severity { Severity::Stable }
fn tier(&self) -> ObservationTier { ObservationTier::Primitive }
fn payload(&self) -> Option<&()> { Some(self) }
fn into_payload(self) -> Option<()> { Some(self) }
}
impl GlassStable<()> for () {
fn value(&self) -> Observation<&()> {
unimplemented!("Cannot be Dereferenced")
}
fn into_value(self) -> Observation<()> {
Observation {
position: &PARENTHETICAL_ENCLOSURE_TOPOLOGY_ANCH0R,
severity: Severity::Stable,
tier: ObservationTier::Primitive,
annotation: Annotation::None,
temporal: Temporal::Current,
payload: self.into_payload(),
}
}
}
static STR_TOPOLOGY_ANCH0R: TopologySegment = TopologySegment {
label: "Daemonic::Glass::Primitives::str",
hash: const_daemonic_hash(
"Daemonic::Glass::Primitives::str".as_bytes(),
AXIOM_OFFSET,
),
crypto_id: const_daemonic_hash("Daemonic::Glass::Primitives::str".as_bytes(), TOPOLOGY_ANCHOR),
depth: 3u16,
};
#[allow(unsafe_code)]
unsafe impl DaemonicSystemCall for str {}
impl Glass<str> for str {
type Anchor = TopologySegment;
fn position(&self) -> &TopologySegment {
&STR_TOPOLOGY_ANCH0R
}
fn severity(&self) -> Severity {
Severity::Stable
}
fn payload(&self) -> Option<&str> {
Some(self)
}
fn into_payload(self) -> Option<str>
where
Self: Sized,
{
unreachable!()
}
}
impl GlassStable<str> for str
where
Self: Sized,
{
fn value(&self) -> Observation<&str> {
Observation {
position: &STR_TOPOLOGY_ANCH0R,
severity: Severity::Stable,
tier: ObservationTier::Primitive,
annotation: Annotation::None,
temporal: Temporal::Current,
payload: self.payload(),
}
}
#[allow(dead_code)]
fn into_value(self) -> Observation<str>
where
Self: Sized,
{
#[allow(unsafe_code)]
unsafe { unreachable_unchecked() }
}
}
macro_rules! impl_glass_containers {
($($anchor:ident, $upper:ident = $ty:ident),* $(,)?) => {
$(
pub(crate) static $anchor: TopologySegment = TopologySegment {
label: concat!("Daemonic::Glass::Containers::", stringify!($ty)),
hash: const_daemonic_hash(
concat!("Daemonic::Glass::Containers::", stringify!($ty)).as_bytes(),
AXIOM_OFFSET,
),
crypto_id: const_daemonic_hash(
concat!("Daemonic::Glass::Containers::", stringify!($ty)).as_bytes(),
TOPOLOGY_ANCHOR,
),
depth: 3u16,
};
#[allow(unsafe_code)]
unsafe impl DaemonicSystemCall for $ty {}
impl Glass<$ty> for $ty {
type Anchor = $ty;
fn position(&self) -> &TopologySegment { &$anchor }
fn severity(&self) -> Severity { Severity::Stable }
fn tier(&self) -> ObservationTier { ObservationTier::Primitive }
fn payload(&self) -> Option<&$ty> { Some(self) }
fn into_payload(self) -> Option<$ty> { Some(self) }
}
impl GlassStable<$ty> for $ty {
fn value(&self) -> Observation<$ty> {
Observation {
position: &$anchor,
severity: Severity::Stable,
tier: ObservationTier::Primitive,
annotation: Annotation::None,
temporal: Temporal::Current,
payload: *self.payload(),
}
}
fn into_value(self) -> Observation<$ty> {
Observation {
position: &$anchor,
severity: Severity::Stable,
tier: ObservationTier::Primitive,
annotation: Annotation::None,
temporal: Temporal::Current,
payload: self.into_payload(),
}
}
}
)*
};
}
static VEC_TOPOLOGY_ANCH0R: TopologySegment = TopologySegment {
label: "Daemonic::Glass::Containers::Vec<T>",
hash: const_daemonic_hash(
"Daemonic::Glass::Containers::Vec<T>".as_bytes(),
AXIOM_OFFSET,
),
crypto_id: const_daemonic_hash("Daemonic::Glass::Containers::Vec<T>".as_bytes(), TOPOLOGY_ANCHOR),
depth: 3u16,
};
impl<T> Glass<Vec<T>> for Vec<T>
where
T: Glass<T>,
Self: Send + Sync,
{
type Anchor = TopologySegment;
fn position(&self) -> &TopologySegment {
&VEC_TOPOLOGY_ANCH0R
}
fn severity(&self) -> Severity {
if self.is_empty() {
Severity::Unknown } else {
Severity::Stable }
}
fn payload(&self) -> Option<&Vec<T>> {
Some(self)
}
fn into_payload(self) -> Option<Vec<T>> {
Some(self)
}
}
impl<T> GlassStable<Vec<T>> for Vec<T>
where
T: Glass<T>,
Self: Glass<Vec<T>>,
{
fn value(&self) -> Observation<&Vec<T>> {
Observation {
position: &VEC_TOPOLOGY_ANCH0R,
severity: self.severity(),
tier: ObservationTier::Primitive,
annotation: Annotation::None,
temporal: Temporal::Current,
payload: self.payload(),
}
}
fn into_value(self) -> Observation<Vec<T>> {
Observation {
position: &VEC_TOPOLOGY_ANCH0R,
severity: self.severity(),
tier: ObservationTier::Primitive,
annotation: Annotation::None,
temporal: Temporal::Current,
payload: self.into_payload(),
}
}
}
impl<'error, T> DaemonicError<'error> for Vec<T>
where
Self: Glass<Vec<T>>,
T: Glass<T> + 'error,
{
fn position(&self) -> &TopologySegment {
&VEC_TOPOLOGY_ANCH0R
}
fn emit(&self) -> Error {
Error::Daemonic(Daemonic::Glass(Containers(GlassVec(crate::daemonic::glass::daemonic::glass::GlassVecError {
msg: "Im not sure how a Vec container could break, but this is the first hand written attempt so fuck it".to_string(),
}))))
}
}
impl<T> GlassCracked<Vec<T>> for Vec<T>
where
T: Glass<T> + 'static, Self: Glass<Vec<T>>,
{
fn is_holding(&self) -> bool {
!self.is_empty()
}
fn repair(&self) -> Option<&dyn Fn(&Vec<T>) -> bool> {
None }
}
static VECDEQUE_TOPOLOGY_ANCH0R: TopologySegment = TopologySegment {
label: "Daemonic::Glass::Containers::VecDeque<T>",
hash: const_daemonic_hash(
"Daemonic::Glass::Containers::VecDeque<T>".as_bytes(),
AXIOM_OFFSET,
),
crypto_id: const_daemonic_hash("Daemonic::Glass::Containers::VecDeque<T>".as_bytes(), TOPOLOGY_ANCHOR),
depth: 3u16,
};
impl<T> Glass<VecDeque<T>> for VecDeque<T>
where
T: Glass<T>,
{
type Anchor = TopologySegment;
fn position(&self) -> &TopologySegment {
&VECDEQUE_TOPOLOGY_ANCH0R
}
fn severity(&self) -> Severity {
if self.is_empty() {
Severity::Unknown } else {
Severity::Stable }
}
fn payload(&self) -> Option<&VecDeque<T>> {
Some(self)
}
fn into_payload(self) -> Option<VecDeque<T>> {
Some(self)
}
}
impl<T> GlassStable<VecDeque<T>> for VecDeque<T>
where
T: Glass<T>,
Self: Glass<VecDeque<T>>,
{
fn value(&self) -> Observation<&VecDeque<T>> {
Observation::stable(self, &TopologySegment::new("Daemonic::Glass::Containers::VecDeque<T>"))
}
fn into_value(self) -> Observation<VecDeque<T>> {
Observation::stable(self, &TopologySegment::new("Daemonic::Glass::Containers::VecDeque<T>"))
}
}
impl<'error, T> DaemonicError<'error> for VecDeque<T>
where
Self: Glass<VecDeque<T>>,
T: Glass<T> + 'error,
{
fn position(&self) -> &TopologySegment {
&VECDEQUE_TOPOLOGY_ANCH0R
}
fn emit(&self) -> Error {
todo!()
}
}
impl<T> GlassCracked<VecDeque<T>> for VecDeque<T>
where
T: Glass<T> + 'static,
Self: Glass<VecDeque<T>>,
{
fn is_holding(&self) -> bool {
!self.is_empty()
}
fn repair(&self) -> Option<&dyn Fn(&VecDeque<T>) -> bool> {
None }
}
impl<T> Glass<LinkedList<T>> for LinkedList<T>
where
T: Glass<T>,
Self: Send + Sync,
{
type Anchor = TopologySegment;
fn position(&self) -> &TopologySegment {
&VECDEQUE_TOPOLOGY_ANCH0R
}
fn severity(&self) -> Severity {
if self.is_empty() {
Severity::Unknown } else {
Severity::Stable }
}
fn payload(&self) -> Option<&LinkedList<T>> {
Some(&self)
}
fn into_payload(self) -> Option<LinkedList<T>> {
Some(self)
}
}
static LINKED_LIST_TOPOLOGY_ANCH0R: TopologySegment = TopologySegment {
label: "Daemonic::Glass::Containers::LinkedList<T>",
hash: const_daemonic_hash(
"Daemonic::Glass::Containers::LinkedList<T>".as_bytes(),
AXIOM_OFFSET,
),
crypto_id: const_daemonic_hash("Daemonic::Glass::Containers::LinkedList<T>".as_bytes(), TOPOLOGY_ANCHOR),
depth: 3u16,
};
impl<T> GlassStable<LinkedList<T>> for LinkedList<T>
where
T: Glass<T>,
Self: Glass<LinkedList<T>>,
{
fn value(&self) -> Observation<&LinkedList<T>> {
Observation::stable(self, &LINKED_LIST_TOPOLOGY_ANCH0R)
}
fn into_value(self) -> Observation<LinkedList<T>> {
Observation::stable(self, &LINKED_LIST_TOPOLOGY_ANCH0R)
}
}
impl<'error, T> DaemonicError<'error> for LinkedList<T>
where
T: Glass<T> + 'static,
Self: Glass<LinkedList<T>>,
{
fn position(&self) -> &TopologySegment {
&LINKED_LIST_TOPOLOGY_ANCH0R
}
fn emit(&self) -> Error {
todo!()
}
}
impl<T> GlassCracked<LinkedList<T>> for LinkedList<T>
where
T: Glass<T> + 'static,
Self: Glass<LinkedList<T>>,
{
fn is_holding(&self) -> bool {
!self.is_empty()
}
fn repair(&self) -> Option<&dyn Fn(&LinkedList<T>) -> bool> {
None }
}
static BTREE_MAP_LIST_TOPOLOGY_ANCH0R: TopologySegment = TopologySegment {
label: "Daemonic::Glass::Containers::BTreeMap<K, V>",
hash: const_daemonic_hash(
"Daemonic::Glass::Containers::BTreeMap<K, V>".as_bytes(),
AXIOM_OFFSET,
),
crypto_id: const_daemonic_hash("Daemonic::Glass::Containers::BTreeMap<K, V>".as_bytes(), TOPOLOGY_ANCHOR),
depth: 3u16,
};
impl<K, V> Glass<BTreeMap<K, V>> for BTreeMap<K, V>
where
K: Glass<K>,
V: Glass<V>,
Self: Send + Sync,
{
type Anchor = TopologySegment;
fn position(&self) -> &TopologySegment {
&BTREE_MAP_LIST_TOPOLOGY_ANCH0R
}
fn severity(&self) -> Severity {
if self.is_empty() {
Severity::Unknown } else {
Severity::Stable }
}
fn payload(&self) -> Option<&BTreeMap<K, V>> {
Some(self)
}
fn into_payload(self) -> Option<BTreeMap<K, V>> {
Some(self)
}
}
impl<K, V> GlassStable<BTreeMap<K, V>> for BTreeMap<K, V>
where
K: Glass<K>,
V: Glass<V>,
Self: Glass<BTreeMap<K, V>>,
{
fn value(&self) -> Observation<&BTreeMap<K, V>> {
Observation::stable(&self, &BTREE_MAP_LIST_TOPOLOGY_ANCH0R)
}
fn into_value(self) -> Observation<BTreeMap<K, V>> {
Observation::stable(self, &BTREE_MAP_LIST_TOPOLOGY_ANCH0R)
}
}
impl<'error, K, V> DaemonicError<'error> for BTreeMap<K, V>
where
K: Glass<K> + 'static,
V: Glass<V> + 'static,
Self: Glass<BTreeMap<K, V>>,
{
fn position(&self) -> &TopologySegment {
&BTREE_MAP_LIST_TOPOLOGY_ANCH0R
}
fn emit(&self) -> Error {
todo!()
}
}
impl<K, V> GlassCracked<BTreeMap<K, V>> for BTreeMap<K, V>
where
K: Glass<K> + 'static,
V: Glass<V> + 'static,
Self: Glass<BTreeMap<K, V>>,
{
fn is_holding(&self) -> bool {
!self.is_empty()
}
fn repair(&self) -> Option<&dyn Fn(&BTreeMap<K, V>) -> bool> {
None }
}
static BTREE_SET_TOPOLOGY_ANCH0R: TopologySegment = TopologySegment {
label: "Daemonic::Glass::Containers::BTreeSet<T>",
hash: const_daemonic_hash(
"Daemonic::Glass::Containers::BTreeSet<T>".as_bytes(),
AXIOM_OFFSET,
),
crypto_id: const_daemonic_hash("Daemonic::Glass::Containers::BTreeSet<T>".as_bytes(), TOPOLOGY_ANCHOR),
depth: 3u16,
};
impl<T> Glass<BTreeSet<T>> for BTreeSet<T>
where
T: Glass<T> + 'static,
Self: Send + Sync,
{
type Anchor = TopologySegment;
fn position(&self) -> &TopologySegment {
&BTREE_SET_TOPOLOGY_ANCH0R
}
fn severity(&self) -> Severity {
if self.is_empty() {
Severity::Unknown } else {
Severity::Stable }
}
fn payload(&self) -> Option<&BTreeSet<T>> {
Some(self)
}
fn into_payload(self) -> Option<BTreeSet<T>> {
Some(self)
}
}
impl<T> GlassStable<BTreeSet<T>> for BTreeSet<T>
where
T: Glass<T>,
Self: Glass<BTreeSet<T>>,
{
fn value(&self) -> Observation<&BTreeSet<T>> {
Observation::stable(&self, &BTREE_SET_TOPOLOGY_ANCH0R)
}
fn into_value(self) -> Observation<BTreeSet<T>> {
Observation::stable(self, &BTREE_SET_TOPOLOGY_ANCH0R)
}
}
impl<'error, T> DaemonicError<'error> for BTreeSet<T>
where
Self: Glass<BTreeSet<T>>,
T: Glass<T> + 'error,
{
fn position(&self) -> &TopologySegment {
&BTREE_SET_TOPOLOGY_ANCH0R
}
fn emit(&self) -> Error {
todo!()
}
}
impl<T> GlassCracked<BTreeSet<T>> for BTreeSet<T>
where
T: Glass<T> + 'static,
Self: Glass<BTreeSet<T>>,
{
fn is_holding(&self) -> bool {
!self.is_empty()
}
fn repair(&self) -> Option<&dyn Fn(&BTreeSet<T>) -> bool> {
None }
}
static GENERIC_ARRAY_TOPOLOGY_ANCH0R: TopologySegment = TopologySegment {
label: "Daemonic::Glass::Containers::[T; N]",
hash: const_daemonic_hash(
"Daemonic::Glass::Containers::[T; N]".as_bytes(),
AXIOM_OFFSET,
),
crypto_id: const_daemonic_hash("Daemonic::Glass::Containers::[T; N]".as_bytes(), TOPOLOGY_ANCHOR),
depth: 3u16,
};
impl<T, const N: usize> Glass<[T; N]> for [T; N]
where
T: Glass<T>,
Self: Send + Sync,
{
type Anchor = TopologySegment;
fn position(&self) -> &TopologySegment {
&GENERIC_ARRAY_TOPOLOGY_ANCH0R
}
fn severity(&self) -> Severity {
if N == 0 {
Severity::Unknown } else {
Severity::Stable
}
}
fn payload(&self) -> Option<&[T; N]> {
Some(self)
}
fn into_payload(self) -> Option<[T; N]> {
Some(self)
}
}
impl<T, const N: usize> GlassStable<[T; N]> for [T; N]
where
T: Glass<T>,
Self: Glass<[T; N]>,
{
fn value(&self) -> Observation<&[T; N]> {
Observation::stable(&self, &GENERIC_ARRAY_TOPOLOGY_ANCH0R)
}
fn into_value(self) -> Observation<[T; N]> {
Observation::stable(self, &GENERIC_ARRAY_TOPOLOGY_ANCH0R)
}
}
impl<'error, T, const N: usize> DaemonicError<'error> for [T; N]
where
Self: Glass<[T; N]>,
T: Glass<T> +'error,
{
fn position(&self) -> &TopologySegment {
&GENERIC_ARRAY_TOPOLOGY_ANCH0R
}
fn emit(&self) -> Error {
todo!()
}
}
impl<T, const N: usize> GlassCracked<[T; N]> for [T; N]
where
T: Glass<T> + 'static,
Self: Glass<[T; N]>,
{
fn is_holding(&self) -> bool {
N > 0
}
fn repair(&self) -> Option<&dyn Fn(&[T; N]) -> bool> {
None }
}
static GENERIC_ARRAY2_TOPOLOGY_ANCH0R: TopologySegment = TopologySegment {
label: "Daemonic::Glass::Containers::[T]",
hash: const_daemonic_hash(
"Daemonic::Glass::Containers::[T]".as_bytes(),
AXIOM_OFFSET,
),
crypto_id: const_daemonic_hash("Daemonic::Glass::Containers::[T]".as_bytes(), TOPOLOGY_ANCHOR),
depth: 3u16,
};
impl<T> Glass<[T]> for [T]
where
T: Glass<T>,
{
type Anchor = TopologySegment;
fn position(&self) -> &TopologySegment {
&GENERIC_ARRAY2_TOPOLOGY_ANCH0R
}
fn severity(&self) -> Severity {
if self.is_empty() {
Severity::Unknown } else {
Severity::Stable }
}
fn payload(&self) -> Option<&[T]> {
Some(self)
}
fn into_payload(self) -> Option<[T]>
where Self: Sized {
Some(self)
}
}
impl<T> GlassStable<[T]> for [T]
where
Self: Sized,
T: Glass<T>,
{
fn value(&self) -> Observation<&[T]> {
Observation::stable(&self, &GENERIC_ARRAY2_TOPOLOGY_ANCH0R)
}
fn into_value(self) -> Observation<[T]>
where
Self: Sized,
{
Observation::stable(self, &GENERIC_ARRAY2_TOPOLOGY_ANCH0R)
}
}
impl<'error, T: 'error> DaemonicError<'error> for [T] {
fn position(&self) -> &TopologySegment {
&GENERIC_ARRAY2_TOPOLOGY_ANCH0R
}
fn emit(&self) -> Error {
todo!()
}
}
impl<T> GlassCracked<[T]> for [T]
where
T: Glass<T> + 'static,
Self: Sized,
{
fn is_holding(&self) -> bool {
!self.is_empty()
}
fn repair(&self) -> Option<&dyn Fn(&[T]) -> bool> {
None }
}
static BOX_POINTER_TOPOLOGY_ANCH0R: TopologySegment = TopologySegment {
label: "Daemonic::Glass::Containers::Box<T>",
hash: const_daemonic_hash(
"Daemonic::Glass::Containers::Box<T>".as_bytes(),
AXIOM_OFFSET,
),
crypto_id: const_daemonic_hash("Daemonic::Glass::Containers::Box<T>".as_bytes(), TOPOLOGY_ANCHOR),
depth: 3u16,
};
impl<T> Glass<Box<T>> for Box<T>
where
T: Glass<T> + 'static,
Self: Send + Sync,
{
type Anchor = TopologySegment;
fn position(&self) -> &TopologySegment {
&BOX_POINTER_TOPOLOGY_ANCH0R
}
fn severity(&self) -> Severity {
(**self).severity()
}
fn payload(&self) -> Option<&Box<T>> {
Some(self)
}
fn into_payload(self) -> Option<Box<T>> {
Some(self)
}
}
impl<T> GlassStable<Box<T>> for Box<T>
where
T: Glass<T> + 'static,
Self: Send + Sync,
{
fn value(&self) -> Observation<&Box<T>> {
Observation::stable(&self, &BOX_POINTER_TOPOLOGY_ANCH0R)
}
fn into_value(self) -> Observation<Box<T>> {
Observation::stable(self, &BOX_POINTER_TOPOLOGY_ANCH0R)
}
}
static RC_POINTER_TOPOLOGY_ANCH0R: TopologySegment = TopologySegment {
label: "Daemonic::Glass::Containers::Rc<T>",
hash: const_daemonic_hash(
"Daemonic::Glass::Containers::Rc<T>".as_bytes(),
AXIOM_OFFSET,
),
crypto_id: const_daemonic_hash("Daemonic::Glass::Containers::Rc<T>".as_bytes(), TOPOLOGY_ANCHOR),
depth: 3u16,
};
impl<T> Glass<T> for Rc<T>
where
T: Glass<T>,
{
type Anchor = TopologySegment;
fn position(&self) -> &TopologySegment {
&RC_POINTER_TOPOLOGY_ANCH0R
}
fn severity(&self) -> Severity {
(**self).severity()
}
fn payload(&self) -> Option<&T> {
Some(&self)
}
fn into_payload(self) -> Option<T> {
todo!()
}
}
impl<T> Glass<Rc<T>> for Rc<T>
where
T: Glass<T>,
{
type Anchor = TopologySegment;
fn position(&self) -> &TopologySegment {
todo!()
}
fn severity(&self) -> Severity {
todo!()
}
fn payload(&self) -> Option<&Rc<T>> {
todo!()
}
fn into_payload(self) -> Option<Rc<T>>
where
Self: Sized,
Rc<T>: Sized
{
todo!()
}
}
impl<T> GlassStable<Rc<T>> for Rc<T>
where
T: Glass<T>,
{
fn value(&self) -> Observation<&Rc<T>> {
Observation::stable(&self, &RC_POINTER_TOPOLOGY_ANCH0R)
}
fn into_value(self) -> Observation<Rc<T>> {
Observation::stable(self, &RC_POINTER_TOPOLOGY_ANCH0R)
}
}
static ARC_POINTER_TOPOLOGY_ANCH0R: TopologySegment = TopologySegment {
label: "Daemonic::Glass::Containers::Arc<T>",
hash: const_daemonic_hash(
"Daemonic::Glass::Containers::Arc<T>".as_bytes(),
AXIOM_OFFSET,
),
crypto_id: const_daemonic_hash("Daemonic::Glass::Containers::Arc<T>".as_bytes(), TOPOLOGY_ANCHOR),
depth: 3u16,
};
impl<T> Glass<Arc<T>> for Arc<T>
where
T: Glass<T>,
{
type Anchor = TopologySegment;
fn position(&self) -> &TopologySegment {
&ARC_POINTER_TOPOLOGY_ANCH0R
}
fn severity(&self) -> Severity {
(**self).severity()
}
fn payload(&self) -> Option<&Arc<T>> {
Some(self)
}
fn into_payload(self) -> Option<Arc<T>> {
Some(self)
}
}
impl<T> GlassStable<Arc<T>> for Arc<T>
where
T: Glass<T>,
{
fn value(&self) -> Observation<&Arc<T>> {
Observation::stable(&self, &ARC_POINTER_TOPOLOGY_ANCH0R)
}
fn into_value(self) -> Observation<Arc<T>> {
Observation::stable(self, &ARC_POINTER_TOPOLOGY_ANCH0R)
}
}
static GENERIC_REFERENCE_POINTER_TOPOLOGY_ANCH0R: TopologySegment = TopologySegment {
label: "Daemonic::Glass::Containers::&T",
hash: const_daemonic_hash(
"Daemonic::Glass::Containers::&T".as_bytes(),
AXIOM_OFFSET,
),
crypto_id: const_daemonic_hash("Daemonic::Glass::Containers::&T".as_bytes(), TOPOLOGY_ANCHOR),
depth: 3u16,
};
impl<T> Glass<Option<T>> for Option<T>
where
T: Glass<T>,
Self: Send + Sync,
{
type Anchor = TopologySegment;
fn position(&self) -> &TopologySegment {
&OPTION_TOPOLOGY_ANCH0R
}
fn severity(&self) -> Severity {
match self {
Some(_) => Severity::Stable,
None => Severity::Unknown, }
}
fn payload(&self) -> Option<&Option<T>> {
Some(self)
}
fn into_payload(self) -> Option<Option<T>> {
Some(self)
}
}
static OPTION_TOPOLOGY_ANCH0R: TopologySegment = TopologySegment {
label: "Daemonic::Glass::Containers::Option<T>",
hash: const_daemonic_hash(
"Daemonic::Glass::Containers::Option<T>".as_bytes(),
AXIOM_OFFSET,
),
crypto_id: const_daemonic_hash("Daemonic::Glass::Containers::Option<T>".as_bytes(), TOPOLOGY_ANCHOR),
depth: 3u16,
};
impl<T> GlassStable<Option<T>> for Option<T>
where
T: Glass<T>,
Self: Glass<Option<T>>,
{
fn value(&self) -> Observation<&Option<T>> {
Observation::stable(&self, &OPTION_TOPOLOGY_ANCH0R)
}
fn into_value(self) -> Observation<Option<T>> {
Observation::stable(self, &OPTION_TOPOLOGY_ANCH0R)
}
}
impl<'error, T> DaemonicError<'error> for Option<T>
where
Self: Glass<Option<T>>,
T: Glass<T> + 'error,
{
fn position(&self) -> &TopologySegment {
&OPTION_TOPOLOGY_ANCH0R
}
fn emit(&self) -> Error {
todo!()
}
}
impl<T> GlassCracked<Option<T>> for Option<T>
where
T: Glass<T> + 'static,
Self: Glass<Option<T>>,
{
fn is_holding(&self) -> bool {
self.is_some()
}
fn repair(&self) -> Option<&dyn Fn(&Option<T>) -> bool> {
None }
}
static RESULT_TOPOLOGY_ANCH0R: TopologySegment = TopologySegment {
label: "Daemonic::Glass::Containers::Result<T, E>",
hash: const_daemonic_hash(
"Daemonic::Glass::Containers::Result<T, E>".as_bytes(),
AXIOM_OFFSET,
),
crypto_id: const_daemonic_hash("Daemonic::Glass::Containers::Result<T, E>".as_bytes(), TOPOLOGY_ANCHOR),
depth: 3u16,
};
impl<T, E> Glass<Result<T, E>> for Result<T, E>
where
T: Glass<T>,
E: Glass<E>,
Self: Send + Sync,
{
type Anchor = TopologySegment;
fn position(&self) -> &TopologySegment {
&RESULT_TOPOLOGY_ANCH0R
}
fn severity(&self) -> Severity {
match self {
Ok(_) => Severity::Stable,
Err(_) => Severity::Shattered, }
}
fn payload(&self) -> Option<&Result<T, E>> {
Some(self)
}
fn into_payload(self) -> Option<Result<T, E>> {
Some(self)
}
}