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