-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathmod.rs
More file actions
113 lines (93 loc) · 2.91 KB
/
Copy pathmod.rs
File metadata and controls
113 lines (93 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//
// Copyright (c) The Holo Core Contributors
//
// SPDX-License-Identifier: MIT
//
pub mod configuration;
pub mod notification;
pub mod rpc;
pub mod state;
pub mod yang;
use holo_northbound as northbound;
use holo_northbound::ProviderBase;
use holo_yang::ToYang;
use tracing::{Span, debug_span};
use crate::instance::Instance;
use crate::version::{Ospfv2, Ospfv3, Version};
pub trait NorthboundVersion<V: Version> {
fn debug_span(name: &str) -> Span;
fn validation_callbacks()
-> Option<&'static northbound::configuration::ValidationCallbacks>;
fn configuration_callbacks()
-> &'static northbound::configuration::Callbacks<Instance<V>>;
fn rpc_callbacks() -> &'static northbound::rpc::Callbacks<Instance<V>>;
fn state_callbacks() -> &'static northbound::state::Callbacks<Instance<V>>;
}
// ===== impl Instance =====
impl<V> ProviderBase for Instance<V>
where
V: Version,
{
fn yang_modules() -> &'static [&'static str] {
&[
"ietf-ospf",
"ietf-ospf-sr-mpls",
"ietf-ospfv3-extended-lsa",
"holo-ospf",
"holo-ospf-dev",
"holo-ospf-reverse-metric",
]
}
fn top_level_node(&self) -> String {
format!(
"/ietf-routing:routing/control-plane-protocols/control-plane-protocol[type='{}'][name='{}']/ietf-ospf:ospf",
V::PROTOCOL.to_yang(),
self.name
)
}
fn debug_span(name: &str) -> Span {
V::debug_span(name)
}
}
// ===== impl Ospfv2 =====
impl NorthboundVersion<Self> for Ospfv2 {
fn debug_span(name: &str) -> Span {
debug_span!("ospfv2-instance", %name)
}
fn validation_callbacks()
-> Option<&'static northbound::configuration::ValidationCallbacks> {
Some(&configuration::VALIDATION_CALLBACKS_OSPFV2)
}
fn configuration_callbacks()
-> &'static northbound::configuration::Callbacks<Instance<Self>> {
&configuration::CALLBACKS_OSPFV2
}
fn rpc_callbacks() -> &'static northbound::rpc::Callbacks<Instance<Self>> {
&rpc::CALLBACKS_OSPFV2
}
fn state_callbacks() -> &'static northbound::state::Callbacks<Instance<Self>>
{
&state::CALLBACKS_OSPFV2
}
}
// ===== impl Ospfv3 =====
impl NorthboundVersion<Self> for Ospfv3 {
fn debug_span(name: &str) -> Span {
debug_span!("ospfv3-instance", %name)
}
fn validation_callbacks()
-> Option<&'static northbound::configuration::ValidationCallbacks> {
Some(&configuration::VALIDATION_CALLBACKS_OSPFV3)
}
fn configuration_callbacks()
-> &'static northbound::configuration::Callbacks<Instance<Self>> {
&configuration::CALLBACKS_OSPFV3
}
fn rpc_callbacks() -> &'static northbound::rpc::Callbacks<Instance<Self>> {
&rpc::CALLBACKS_OSPFV3
}
fn state_callbacks() -> &'static northbound::state::Callbacks<Instance<Self>>
{
&state::CALLBACKS_OSPFV3
}
}