ipmi_rs/storage/sel/
get_alloc_info.rs

1use crate::{
2    connection::{IpmiCommand, Message, NetFn, ParseResponseError},
3    Loggable,
4};
5
6pub struct GetAllocInfo;
7
8impl IpmiCommand for GetAllocInfo {
9    type Output = AllocInfo;
10
11    type Error = ();
12
13    fn parse_response(
14        completion_code: crate::connection::CompletionCode,
15        data: &[u8],
16    ) -> Result<Self::Output, ParseResponseError<Self::Error>> {
17        Self::check_cc_success(completion_code)?;
18
19        AllocInfo::parse(data).ok_or(ParseResponseError::NotEnoughData)
20    }
21}
22
23impl From<GetAllocInfo> for Message {
24    fn from(_: GetAllocInfo) -> Self {
25        Message::new_request(NetFn::Storage, 0x41, Vec::new())
26    }
27}
28
29pub struct AllocInfo {
30    inner: crate::storage::AllocInfo,
31}
32
33impl AllocInfo {
34    pub fn parse(data: &[u8]) -> Option<Self> {
35        Some(Self {
36            inner: crate::storage::AllocInfo::parse(data)?,
37        })
38    }
39}
40
41impl Loggable for AllocInfo {
42    fn as_log(&self) -> Vec<crate::fmt::LogItem> {
43        let mut alloc_log_output = self.inner.as_log();
44        alloc_log_output.insert(0, (0, "SEL Allocation Information").into());
45        alloc_log_output
46    }
47}
48
49impl core::ops::Deref for AllocInfo {
50    type Target = crate::storage::AllocInfo;
51
52    fn deref(&self) -> &Self::Target {
53        &self.inner
54    }
55}
56
57impl core::ops::DerefMut for AllocInfo {
58    fn deref_mut(&mut self) -> &mut Self::Target {
59        &mut self.inner
60    }
61}