switch to color_eyre instead of anyhow
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -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")));
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user