switch to color_eyre instead of anyhow

This commit is contained in:
Nova
2022-12-02 13:58:54 -05:00
parent 03ccf9127d
commit d7a607a663
29 changed files with 114 additions and 118 deletions

View File

@@ -3,7 +3,7 @@ use crate::{
core::registry::Registry,
nodes::{data, drawable, fields, hmd, input, items, root::Root, spatial, startup, Node},
};
use anyhow::{anyhow, Result};
use color_eyre::eyre::{eyre, Result};
use lazy_static::lazy_static;
use once_cell::sync::OnceCell;
use parking_lot::Mutex;
@@ -104,7 +104,7 @@ impl Client {
pub fn get_node(&self, name: &'static str, path: &str) -> Result<Arc<Node>> {
self.scenegraph
.get_node(path)
.ok_or_else(|| anyhow!("{} not found", name))
.ok_or_else(|| eyre!("{} not found", name))
}
pub async fn disconnect(&self) {

View File

@@ -1,5 +1,5 @@
use super::client::Client;
use anyhow::Result;
use color_eyre::eyre::Result;
use slab::Slab;
use stardust_xr::server;
use std::sync::atomic::AtomicU64;

View File

@@ -6,31 +6,31 @@ use std::{
sync::{Arc, Weak},
};
#[derive(Default)]
pub struct LifeLinkedNodeList {
nodes: Mutex<Vec<Weak<Node>>>,
}
impl LifeLinkedNodeList {
pub fn add(&self, node: Weak<Node>) {
self.nodes.lock().push(node);
}
// #[derive(Default)]
// pub struct LifeLinkedNodeList {
// nodes: Mutex<Vec<Weak<Node>>>,
// }
// impl LifeLinkedNodeList {
// pub fn add(&self, node: Weak<Node>) {
// self.nodes.lock().push(node);
// }
pub fn clear(&self) {
self.nodes
.lock()
.iter()
.filter_map(|node| node.upgrade())
.for_each(|node| {
node.destroy();
});
self.nodes.lock().clear();
}
}
impl Drop for LifeLinkedNodeList {
fn drop(&mut self) {
self.clear();
}
}
// pub fn clear(&self) {
// self.nodes
// .lock()
// .iter()
// .filter_map(|node| node.upgrade())
// .for_each(|node| {
// node.destroy();
// });
// self.nodes.lock().clear();
// }
// }
// impl Drop for LifeLinkedNodeList {
// fn drop(&mut self) {
// self.clear();
// }
// }
#[derive(Default)]
pub struct LifeLinkedNodeMap<K: Hash + Eq> {

View File

@@ -1,4 +1,4 @@
use anyhow::anyhow;
use color_eyre::eyre::eyre;
use serde::{de::Visitor, Deserialize};
use std::path::PathBuf;
@@ -56,9 +56,7 @@ impl<'de> Visitor<'de> for ResourceVisitor {
path: PathBuf::from(path),
}
} else {
return Err(serde::de::Error::custom(anyhow!(
"Invalid format for string"
)));
return Err(serde::de::Error::custom(eyre!("Invalid format for string")));
})
}

View File

@@ -1,6 +1,6 @@
use crate::core::client::Client;
use crate::nodes::Node;
use anyhow::Result;
use color_eyre::eyre::Result;
use once_cell::sync::OnceCell;
use stardust_xr::scenegraph;
use stardust_xr::scenegraph::ScenegraphError;