Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 12 additions & 0 deletions src/core/basic_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Attributes> {
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<Vec<String>> {
Expand Down
3 changes: 3 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ pub enum ClientErrorKind {
NoAuthenticator,
/// Required parameter was not provided
MissingParam,
/// The requested resource was not found.
NotFound,
}

impl From<ClientErrorKind> for Error {
Expand All @@ -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")
}
}
}
Expand Down