scion_stack/path/types.rs
1// Copyright 2025 Anapaya Systems
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Path Manager specific types.
16
17use scion_proto::path;
18
19/// Path wrapper to allow additional metadata to be attached to a path for Ranking and Policies
20#[derive(Debug, Clone)]
21pub struct PathManagerPath {
22 /// The actual SCION path
23 pub path: path::Path,
24 /// If the path was manually registered (true) or fetched (false)
25 pub from_registration: bool,
26}
27
28impl PathManagerPath {
29 /// Wrap a scion path with metadata
30 pub fn new(path: path::Path, from_registration: bool) -> Self {
31 Self {
32 path,
33 from_registration,
34 }
35 }
36
37 /// Returns true if this path came from registration rather than fetching
38 pub fn is_from_registration(&self) -> bool {
39 self.from_registration
40 }
41
42 /// Get the underlying scion path
43 pub fn scion_path(&self) -> &path::Path {
44 &self.path
45 }
46}
47
48impl From<&path::Path> for PathManagerPath {
49 fn from(path: &path::Path) -> Self {
50 Self {
51 path: path.clone(),
52 from_registration: false,
53 }
54 }
55}