Skip to content

Commit a915d9a

Browse files
authored
Merge pull request #71 from ionut-arm/psa-bump
Update interface dependency
2 parents 06c52e2 + c3df198 commit a915d9a

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ edition = "2018"
1313
documentation = "https://docs.rs/crate/parsec-client"
1414

1515
[dependencies]
16-
parsec-interface = { git = "https://github.com/parallaxsecond/parsec-interface-rs", rev = "c8a59544fac04df347f51d19323f4a0b5bb9580d" }
16+
parsec-interface = { git = "https://github.com/parallaxsecond/parsec-interface-rs", rev = "0a20255e5cb73d3c4499a73d147d7c4a2b45ac5f" }
1717
num = "0.3.0"
1818
log = "0.4.11"
1919
derivative = "2.1.1"

src/core/basic_client.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,18 @@ impl BasicClient {
377377
}
378378
}
379379

380+
/// Get the key attributes.
381+
///
382+
/// This is a convenience method that uses `list_keys` underneath.
383+
pub fn key_attributes(&self, key_name: &str) -> Result<Attributes> {
384+
Ok(self
385+
.list_keys()?
386+
.into_iter()
387+
.find(|key_info| key_info.name == key_name)
388+
.ok_or(crate::error::Error::Client(ClientErrorKind::NotFound))?
389+
.attributes)
390+
}
391+
380392
/// **[Core Operation, Admin Operation]** Lists all clients currently having
381393
/// data in the service.
382394
pub fn list_clients(&self) -> Result<Vec<String>> {

src/error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ pub enum ClientErrorKind {
4242
NoAuthenticator,
4343
/// Required parameter was not provided
4444
MissingParam,
45+
/// The requested resource was not found.
46+
NotFound,
4547
}
4648

4749
impl From<ClientErrorKind> for Error {
@@ -65,6 +67,7 @@ impl fmt::Display for ClientErrorKind {
6567
ClientErrorKind::NoProvider => write!(f, "client is missing an implicit provider"),
6668
ClientErrorKind::NoAuthenticator => write!(f, "service is not reporting any authenticators or none of the reported ones are supported by the client"),
6769
ClientErrorKind::MissingParam => write!(f, "one of the `Option` parameters was required but was not provided"),
70+
ClientErrorKind::NotFound => write!(f, "one of the resources required in the operation was not found")
6871
}
6972
}
7073
}

0 commit comments

Comments
 (0)