Skip to main content

link_cli/sequences/
target_matcher.rs

1use crate::link_storage::LinkStorage;
2
3#[derive(Clone, Copy, Debug, Eq, PartialEq)]
4pub struct TargetMatcher {
5    target: u32,
6}
7
8impl TargetMatcher {
9    pub fn new(target: u32) -> Self {
10        Self { target }
11    }
12
13    pub fn target(&self) -> u32 {
14        self.target
15    }
16
17    pub fn is_matched(&self, links: &LinkStorage, link: u32) -> bool {
18        links
19            .get(link)
20            .is_some_and(|candidate| candidate.target == self.target)
21    }
22}