Skip to content

Commit 8b23c2b

Browse files
committed
[platform_device_loader] rework SavePkiLocalPendingError
1 parent 316ecbc commit 8b23c2b

File tree

1 file changed

+21
-2
lines changed
  • libparsec/crates/platform_device_loader/src

1 file changed

+21
-2
lines changed

libparsec/crates/platform_device_loader/src/pki.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,31 @@ use crate::{get_local_pending_dir, LOCAL_PENDING_EXT};
1212

1313
#[derive(Debug, thiserror::Error)]
1414
pub enum SavePkiLocalPendingError {
15-
#[error(transparent)]
16-
SaveContentError(#[from] SaveContentError),
15+
#[error("No space available")]
16+
NoSpaceAvailable,
17+
#[error("invalid path")]
18+
InvalidPath,
1719
#[error(transparent)]
1820
Internal(anyhow::Error),
1921
}
2022

23+
impl From<SaveContentError> for SavePkiLocalPendingError {
24+
fn from(value: SaveContentError) -> Self {
25+
match value {
26+
SaveContentError::NotAFile
27+
| SaveContentError::InvalidParent
28+
| SaveContentError::InvalidPath
29+
| SaveContentError::ParentNotFound
30+
| SaveContentError::CannotEdit => SavePkiLocalPendingError::InvalidPath,
31+
32+
SaveContentError::StorageNotAvailable | SaveContentError::NoSpaceLeft => {
33+
SavePkiLocalPendingError::NoSpaceAvailable
34+
}
35+
SaveContentError::Internal(_) => SavePkiLocalPendingError::Internal(value.into()),
36+
}
37+
}
38+
}
39+
2140
pub async fn save_pki_local_pending(
2241
local_pending: PKILocalPendingEnrollment,
2342
local_file: PathBuf,

0 commit comments

Comments
 (0)