aboutsummaryrefslogtreecommitdiff
path: root/common/object/src/inspect.rs
diff options
context:
space:
mode:
Diffstat (limited to 'common/object/src/inspect.rs')
-rw-r--r--common/object/src/inspect.rs59
1 files changed, 0 insertions, 59 deletions
diff --git a/common/object/src/inspect.rs b/common/object/src/inspect.rs
deleted file mode 100644
index cfab5c3..0000000
--- a/common/object/src/inspect.rs
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- This file is part of jellything (https://codeberg.org/metamuffin/jellything)
- which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
- Copyright (C) 2026 metamuffin <metamuffin.org>
-*/
-
-use crate::{Object, Registry, Tag, TypedTag, types::*};
-use std::{any::type_name, fmt::Debug};
-
-pub struct Inspector<'a, T>(pub &'a Registry, pub T);
-
-impl Debug for Inspector<'_, Object<'_>> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- let mut s = f.debug_struct("Object");
- let mut nonexhaustive = false;
- for (i, k) in self.1.keys().enumerate() {
- let Some(info) = self.0.info(k) else {
- nonexhaustive = true;
- continue;
- };
- let Some(ty) = info.r#type else {
- nonexhaustive = true;
- continue;
- };
- match ty {
- x if x == STR => s.field(info.name, &self.1.get_typed::<&str>(i).unwrap()),
- x if x == BINARY => s.field(info.name, &self.1.get_typed::<&[u8]>(i).unwrap()),
- x if x == OBJECT => s.field(info.name, &self.1.get_typed::<Object>(i).unwrap()),
- x if x == U32 => s.field(info.name, &self.1.get_typed::<u32>(i).unwrap()),
- x if x == U64 => s.field(info.name, &self.1.get_typed::<u64>(i).unwrap()),
- x if x == I64 => s.field(info.name, &self.1.get_typed::<i64>(i).unwrap()),
- _ => {
- nonexhaustive = true;
- &mut s
- }
- };
- }
- if nonexhaustive {
- s.finish_non_exhaustive()
- } else {
- s.finish()
- }
- }
-}
-
-impl<T> Debug for Inspector<'_, TypedTag<T>> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- let name = self.0.info(self.1.0).map(|t| t.name).unwrap_or("unknown");
- f.debug_tuple(&format!("TypedTag<{}>", type_name::<T>()))
- .field(&name)
- .finish()
- }
-}
-impl Debug for Inspector<'_, Tag> {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- let name = self.0.info(self.1).map(|t| t.name).unwrap_or("unknown");
- f.debug_tuple("Tag").field(&name).finish()
- }
-}