refactor(node): return Result<&T> from get aspect
This commit is contained in:
@@ -209,4 +209,5 @@ pub fn find_field(client: &Client, path: &str) -> Result<Arc<Field>> {
|
|||||||
client
|
client
|
||||||
.get_node("Field", path)?
|
.get_node("Field", path)?
|
||||||
.get_aspect("Field", "info", |n| &n.field)
|
.get_aspect("Field", "info", |n| &n.field)
|
||||||
|
.cloned()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,14 +153,13 @@ impl Node {
|
|||||||
node_name: &'static str,
|
node_name: &'static str,
|
||||||
aspect_type: &'static str,
|
aspect_type: &'static str,
|
||||||
aspect_fn: F,
|
aspect_fn: F,
|
||||||
) -> Result<Arc<T>>
|
) -> Result<&T>
|
||||||
where
|
where
|
||||||
F: FnOnce(&Node) -> &OnceCell<Arc<T>>,
|
F: FnOnce(&Node) -> &OnceCell<T>,
|
||||||
{
|
{
|
||||||
aspect_fn(self)
|
aspect_fn(self)
|
||||||
.get()
|
.get()
|
||||||
.ok_or_else(|| anyhow!("{} is not a {} node", node_name, aspect_type))
|
.ok_or_else(|| anyhow!("{} is not a {} node", node_name, aspect_type))
|
||||||
.cloned()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_local_signal(
|
pub fn send_local_signal(
|
||||||
|
|||||||
@@ -299,6 +299,7 @@ pub fn find_spatial(
|
|||||||
calling_client
|
calling_client
|
||||||
.get_node(node_name, node_path)?
|
.get_node(node_name, node_path)?
|
||||||
.get_aspect(node_name, "spatial", |n| &n.spatial)
|
.get_aspect(node_name, "spatial", |n| &n.spatial)
|
||||||
|
.cloned()
|
||||||
}
|
}
|
||||||
pub fn find_spatial_parent(
|
pub fn find_spatial_parent(
|
||||||
calling_client: &Arc<Client>,
|
calling_client: &Arc<Client>,
|
||||||
|
|||||||
Reference in New Issue
Block a user