diff --git a/Cargo.toml b/Cargo.toml index 56363d0..91eefba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ edition = "2018" documentation = "https://docs.rs/crate/parsec-client" [dependencies] -parsec-interface = { git = "https://github.com/parallaxsecond/parsec-interface-rs", rev = "c8a59544fac04df347f51d19323f4a0b5bb9580d" } +parsec-interface = { git = "https://github.com/parallaxsecond/parsec-interface-rs", rev = "0a20255e5cb73d3c4499a73d147d7c4a2b45ac5f" } num = "0.3.0" log = "0.4.11" derivative = "2.1.1" diff --git a/src/core/basic_client.rs b/src/core/basic_client.rs index df2b43a..f9208ec 100644 --- a/src/core/basic_client.rs +++ b/src/core/basic_client.rs @@ -377,6 +377,18 @@ impl BasicClient { } } + /// Get the key attributes. + /// + /// This is a convenience method that uses `list_keys` underneath. + pub fn key_attributes(&self, key_name: &str) -> Result { + Ok(self + .list_keys()? + .into_iter() + .find(|key_info| key_info.name == key_name) + .ok_or(crate::error::Error::Client(ClientErrorKind::NotFound))? + .attributes) + } + /// **[Core Operation, Admin Operation]** Lists all clients currently having /// data in the service. pub fn list_clients(&self) -> Result> { diff --git a/src/error.rs b/src/error.rs index 28045dc..d7b924a 100644 --- a/src/error.rs +++ b/src/error.rs @@ -42,6 +42,8 @@ pub enum ClientErrorKind { NoAuthenticator, /// Required parameter was not provided MissingParam, + /// The requested resource was not found. + NotFound, } impl From for Error { @@ -65,6 +67,7 @@ impl fmt::Display for ClientErrorKind { ClientErrorKind::NoProvider => write!(f, "client is missing an implicit provider"), ClientErrorKind::NoAuthenticator => write!(f, "service is not reporting any authenticators or none of the reported ones are supported by the client"), ClientErrorKind::MissingParam => write!(f, "one of the `Option` parameters was required but was not provided"), + ClientErrorKind::NotFound => write!(f, "one of the resources required in the operation was not found") } } }