key.len() <= KVSTORE_NAMESPACE_KEY_MAX_LEN && key.chars().all(|c| KVSTORE_NAMESPACE_KEY_ALPHABET.contains(c))
}
-pub(crate) fn check_namespace_key_validity(namespace: &str, sub_namespace: &str, key: Option<&str>, operation: &str) -> Result<(), std::io::Error> {
+pub(crate) fn check_namespace_key_validity(
+ primary_namespace: &str, secondary_namespace: &str, key: Option<&str>, operation: &str)
+-> Result<(), std::io::Error> {
if let Some(key) = key {
if key.is_empty() {
debug_assert!(false, "Failed to {} {}/{}/{}: key may not be empty.", operation,
- PrintableString(namespace), PrintableString(sub_namespace), PrintableString(key));
+ PrintableString(primary_namespace), PrintableString(secondary_namespace), PrintableString(key));
let msg = format!("Failed to {} {}/{}/{}: key may not be empty.", operation,
- PrintableString(namespace), PrintableString(sub_namespace), PrintableString(key));
+ PrintableString(primary_namespace), PrintableString(secondary_namespace), PrintableString(key));
return Err(std::io::Error::new(std::io::ErrorKind::Other, msg));
}
- if namespace.is_empty() && !sub_namespace.is_empty() {
+ if primary_namespace.is_empty() && !secondary_namespace.is_empty() {
debug_assert!(false,
- "Failed to {} {}/{}/{}: namespace may not be empty if a non-empty sub-namespace is given.",
+ "Failed to {} {}/{}/{}: primary namespace may not be empty if a non-empty secondary namespace is given.",
operation,
- PrintableString(namespace), PrintableString(sub_namespace), PrintableString(key));
+ PrintableString(primary_namespace), PrintableString(secondary_namespace), PrintableString(key));
let msg = format!(
- "Failed to {} {}/{}/{}: namespace may not be empty if a non-empty sub-namespace is given.", operation,
- PrintableString(namespace), PrintableString(sub_namespace), PrintableString(key));
+ "Failed to {} {}/{}/{}: primary namespace may not be empty if a non-empty secondary namespace is given.", operation,
+ PrintableString(primary_namespace), PrintableString(secondary_namespace), PrintableString(key));
return Err(std::io::Error::new(std::io::ErrorKind::Other, msg));
}
- if !is_valid_kvstore_str(namespace) || !is_valid_kvstore_str(sub_namespace) || !is_valid_kvstore_str(key) {
- debug_assert!(false, "Failed to {} {}/{}/{}: namespace, sub-namespace, and key must be valid.",
+ if !is_valid_kvstore_str(primary_namespace) || !is_valid_kvstore_str(secondary_namespace) || !is_valid_kvstore_str(key) {
+ debug_assert!(false, "Failed to {} {}/{}/{}: primary namespace, secondary namespace, and key must be valid.",
operation,
- PrintableString(namespace), PrintableString(sub_namespace), PrintableString(key));
- let msg = format!("Failed to {} {}/{}/{}: namespace, sub-namespace, and key must be valid.",
+ PrintableString(primary_namespace), PrintableString(secondary_namespace), PrintableString(key));
+ let msg = format!("Failed to {} {}/{}/{}: primary namespace, secondary namespace, and key must be valid.",
operation,
- PrintableString(namespace), PrintableString(sub_namespace), PrintableString(key));
+ PrintableString(primary_namespace), PrintableString(secondary_namespace), PrintableString(key));
return Err(std::io::Error::new(std::io::ErrorKind::Other, msg));
}
} else {
- if namespace.is_empty() && !sub_namespace.is_empty() {
+ if primary_namespace.is_empty() && !secondary_namespace.is_empty() {
debug_assert!(false,
- "Failed to {} {}/{}: namespace may not be empty if a non-empty sub-namespace is given.",
- operation, PrintableString(namespace), PrintableString(sub_namespace));
+ "Failed to {} {}/{}: primary namespace may not be empty if a non-empty secondary namespace is given.",
+ operation, PrintableString(primary_namespace), PrintableString(secondary_namespace));
let msg = format!(
- "Failed to {} {}/{}: namespace may not be empty if a non-empty sub-namespace is given.",
- operation, PrintableString(namespace), PrintableString(sub_namespace));
+ "Failed to {} {}/{}: primary namespace may not be empty if a non-empty secondary namespace is given.",
+ operation, PrintableString(primary_namespace), PrintableString(secondary_namespace));
return Err(std::io::Error::new(std::io::ErrorKind::Other, msg));
}
- if !is_valid_kvstore_str(namespace) || !is_valid_kvstore_str(sub_namespace) {
- debug_assert!(false, "Failed to {} {}/{}: namespace and sub-namespace must be valid.",
- operation, PrintableString(namespace), PrintableString(sub_namespace));
- let msg = format!("Failed to {} {}/{}: namespace and sub-namespace must be valid.",
- operation, PrintableString(namespace), PrintableString(sub_namespace));
+ if !is_valid_kvstore_str(primary_namespace) || !is_valid_kvstore_str(secondary_namespace) {
+ debug_assert!(false, "Failed to {} {}/{}: primary namespace and secondary namespace must be valid.",
+ operation, PrintableString(primary_namespace), PrintableString(secondary_namespace));
+ let msg = format!("Failed to {} {}/{}: primary namespace and secondary namespace must be valid.",
+ operation, PrintableString(primary_namespace), PrintableString(secondary_namespace));
return Err(std::io::Error::new(std::io::ErrorKind::Other, msg));
}
}