Skip to main content

nv_redfish/manager/
network_protocol.rs

1// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2// SPDX-License-Identifier: Apache-2.0
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//! Manager network protocol resource.
16
17use std::marker::PhantomData;
18use std::sync::Arc;
19
20use nv_redfish_core::{Bmc, NavProperty};
21
22use crate::schema::manager_network_protocol::ManagerNetworkProtocol as ManagerNetworkProtocolSchema;
23use crate::{Error, NvBmc};
24
25/// Network protocol configuration associated with a manager.
26pub struct ManagerNetworkProtocol<B: Bmc> {
27    data: Arc<ManagerNetworkProtocolSchema>,
28    _marker: PhantomData<B>,
29}
30
31impl<B: Bmc> ManagerNetworkProtocol<B> {
32    pub(crate) async fn new(
33        bmc: &NvBmc<B>,
34        nav: &NavProperty<ManagerNetworkProtocolSchema>,
35    ) -> Result<Self, Error<B>> {
36        nav.get(bmc.as_ref())
37            .await
38            .map_err(Error::Bmc)
39            .map(|data| Self {
40                data,
41                _marker: PhantomData,
42            })
43    }
44
45    /// Get the raw schema data for the manager network protocol resource.
46    #[must_use]
47    pub fn raw(&self) -> Arc<ManagerNetworkProtocolSchema> {
48        self.data.clone()
49    }
50}