Skip to content

Commit 43078aa

Browse files
committed
Refactor VSS key extraction
Extract the existing obfuscated key selection so later VSS listing changes can reuse it without changing the parsing behavior. AI-assisted-by: OpenAI Codex
1 parent 3fa778c commit 43078aa

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/io/vss_store.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ impl VssStoreInner {
399399
}
400400
}
401401

402-
fn extract_key(&self, unified_key: &str) -> io::Result<String> {
402+
fn extract_obfuscated_key<'a>(&self, unified_key: &'a str) -> io::Result<&'a str> {
403403
let mut parts = if self.schema_version == VssSchemaVersion::V1 {
404404
let mut parts = unified_key.splitn(2, '#');
405405
let _obfuscated_namespace = parts.next();
@@ -411,14 +411,17 @@ impl VssStoreInner {
411411
parts
412412
};
413413
match parts.next() {
414-
Some(obfuscated_key) => {
415-
let actual_key = self.key_obfuscator.deobfuscate(obfuscated_key)?;
416-
Ok(actual_key)
417-
},
414+
Some(obfuscated_key) => Ok(obfuscated_key),
418415
None => Err(Error::new(ErrorKind::InvalidData, "Invalid key format")),
419416
}
420417
}
421418

419+
fn extract_key(&self, unified_key: &str) -> io::Result<String> {
420+
let obfuscated_key = self.extract_obfuscated_key(unified_key)?;
421+
let actual_key = self.key_obfuscator.deobfuscate(obfuscated_key)?;
422+
Ok(actual_key)
423+
}
424+
422425
async fn list_keys(
423426
&self, client: &VssClient<CustomRetryPolicy>, primary_namespace: &str,
424427
secondary_namespace: &str, key_prefix: String, page_token: Option<String>,

0 commit comments

Comments
 (0)