refactor: remove all explicit lifetime specifiers
This commit is contained in:
@@ -5,12 +5,12 @@ use libstardustxr::messenger::Messenger;
|
||||
use mio::net::UnixStream;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct Client<'a> {
|
||||
messenger: Messenger<'a>,
|
||||
scenegraph: Scenegraph<'a>,
|
||||
pub struct Client {
|
||||
messenger: Messenger,
|
||||
scenegraph: Scenegraph,
|
||||
}
|
||||
|
||||
impl<'a> Client<'a> {
|
||||
impl Client {
|
||||
pub fn from_connection(connection: UnixStream) -> Rc<Self> {
|
||||
let client = Rc::new(Client {
|
||||
messenger: Messenger::new(connection),
|
||||
@@ -25,10 +25,10 @@ impl<'a> Client<'a> {
|
||||
self.messenger.dispatch(&self.scenegraph)
|
||||
}
|
||||
|
||||
pub fn get_messenger(&self) -> &Messenger<'a> {
|
||||
pub fn get_messenger(&self) -> &Messenger {
|
||||
&self.messenger
|
||||
}
|
||||
pub fn get_scenegraph(&self) -> &Scenegraph<'a> {
|
||||
pub fn get_scenegraph(&self) -> &Scenegraph {
|
||||
&self.scenegraph
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,38 +12,38 @@ use dashmap::DashMap;
|
||||
use rustc_hash::FxHasher;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Scenegraph<'a> {
|
||||
client: RefCell<Weak<Client<'a>>>,
|
||||
nodes: DashMap<String, RcCell<Node<'a>>, BuildHasherDefault<FxHasher>>,
|
||||
pub struct Scenegraph {
|
||||
client: RefCell<Weak<Client>>,
|
||||
nodes: DashMap<String, RcCell<Node>, BuildHasherDefault<FxHasher>>,
|
||||
}
|
||||
|
||||
impl<'a> Scenegraph<'a> {
|
||||
pub fn get_client(&self) -> Rc<Client<'a>> {
|
||||
impl Scenegraph {
|
||||
pub fn get_client(&self) -> Rc<Client> {
|
||||
self.client.borrow().upgrade().unwrap()
|
||||
}
|
||||
|
||||
pub fn set_client(&self, client: &Rc<Client<'a>>) {
|
||||
pub fn set_client(&self, client: &Rc<Client>) {
|
||||
*self.client.borrow_mut() = Rc::downgrade(client);
|
||||
}
|
||||
|
||||
pub fn add_node(&self, node: Node<'a>) -> RcCell<Node<'a>> {
|
||||
pub fn add_node(&self, node: Node) -> RcCell<Node> {
|
||||
let path = node.get_path().to_string();
|
||||
let node_rc = RcCell::new(node);
|
||||
self.nodes.insert(path, node_rc.clone());
|
||||
node_rc
|
||||
}
|
||||
|
||||
pub fn get_node(&self, path: &str) -> Option<RcCell<Node<'a>>> {
|
||||
pub fn get_node(&self, path: &str) -> Option<RcCell<Node>> {
|
||||
Some(self.nodes.get(path)?.clone())
|
||||
}
|
||||
|
||||
pub fn remove_node(&self, path: &str) -> Option<RcCell<Node<'a>>> {
|
||||
pub fn remove_node(&self, path: &str) -> Option<RcCell<Node>> {
|
||||
let (_, node) = self.nodes.remove(path)?;
|
||||
Some(node)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> scenegraph::Scenegraph for Scenegraph<'a> {
|
||||
impl scenegraph::Scenegraph for Scenegraph {
|
||||
fn send_signal(&self, path: &str, method: &str, data: &[u8]) -> Result<(), ScenegraphError> {
|
||||
self.get_node(path)
|
||||
.ok_or(ScenegraphError::NodeNotFound)?
|
||||
|
||||
Reference in New Issue
Block a user