forked from eclipse-iceoryx/iceoryx2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[eclipse-iceoryx#98] Implement
iox2 nodes details
- Loading branch information
Showing
8 changed files
with
324 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
// | ||
// See the NOTICE file(s) distributed with this work for additional | ||
// information regarding copyright ownership. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Apache Software License 2.0 which is available at | ||
// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
// which is available at https://opensource.org/licenses/MIT. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
use crate::cli::DetailsFilter; | ||
use crate::cli::ListFilter; | ||
use crate::cli::NodeIdentifier; | ||
use crate::cli::StateFilter; | ||
use iceoryx2::node::NodeState; | ||
use iceoryx2::node::NodeView; | ||
use iceoryx2::service::ipc::Service; | ||
use iceoryx2_cli_utils::output::NodeIdString; | ||
use iceoryx2_cli_utils::Filter; | ||
|
||
impl Filter<NodeState<Service>> for NodeIdentifier { | ||
fn matches(&self, node: &NodeState<Service>) -> bool { | ||
match self { | ||
NodeIdentifier::Name(ref name) => match node { | ||
NodeState::Alive(view) => view | ||
.details() | ||
.as_ref() | ||
.map(|details| details.name().as_str() == name) | ||
.unwrap_or(false), | ||
NodeState::Dead(view) => view | ||
.details() | ||
.as_ref() | ||
.map(|details| details.name().as_str() == name) | ||
.unwrap_or(false), | ||
NodeState::Inaccessible(_) | NodeState::Undefined(_) => false, | ||
}, | ||
NodeIdentifier::Id(ref id) => match node { | ||
NodeState::Alive(view) => NodeIdString::from(view.id()) == **id, | ||
NodeState::Dead(view) => NodeIdString::from(view.id()) == **id, | ||
NodeState::Inaccessible(node_id) => NodeIdString::from(node_id) == **id, | ||
NodeState::Undefined(node_id) => NodeIdString::from(node_id) == **id, | ||
}, | ||
NodeIdentifier::Pid(pid) => match node { | ||
NodeState::Alive(view) => view.id().pid().value() == *pid, | ||
NodeState::Dead(view) => view.id().pid().value() == *pid, | ||
NodeState::Inaccessible(node_id) => node_id.pid().value() == *pid, | ||
NodeState::Undefined(node_id) => node_id.pid().value() == *pid, | ||
}, | ||
} | ||
} | ||
} | ||
|
||
impl Filter<NodeState<Service>> for StateFilter { | ||
fn matches(&self, node: &NodeState<Service>) -> bool { | ||
matches!( | ||
(self, node), | ||
(StateFilter::Alive, NodeState::Alive(_)) | ||
| (StateFilter::Dead, NodeState::Dead(_)) | ||
| (StateFilter::Inaccessible, NodeState::Inaccessible(_)) | ||
| (StateFilter::Undefined, NodeState::Undefined(_)) | ||
| (StateFilter::All, _) | ||
) | ||
} | ||
} | ||
|
||
impl Filter<NodeState<Service>> for ListFilter { | ||
fn matches(&self, node: &NodeState<Service>) -> bool { | ||
self.state.matches(node) | ||
} | ||
} | ||
|
||
impl Filter<NodeState<Service>> for DetailsFilter { | ||
fn matches(&self, node: &NodeState<Service>) -> bool { | ||
self.state.matches(node) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.