You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to reconstruct a KesSecretKey from a base64-encoded string coming from a JSON structure that's generated in Haskell, for the purpose of testing header validation logic. Here is the code I am using:
fn deserialize_secret_kes_key<'a, 'de, D>(deserializer: D) -> Result<KesSecretKey<'a>, D::Error>
where
D: Deserializer<'de>,
{
let buf = <&str>::deserialize(deserializer)?;
let mut bytes = general_purpose::STANDARD
.decode(buf)
.map_err(serde::de::Error::custom)?;
KesSecretKey::from_bytes(&mut bytes).map_err(serde::de::Error::custom)
}
which fails to compile because of
error[E0515]: cannot return value referencing local variable `bytes`
--> ouroboros-praos/tests/validation.rs:35:5
|
35 | KesSecretKey::from_bytes(&mut bytes).map_err(serde::de::Error::custom)
| ^^^^^^^^^^^^^^^^^^^^^^^^^----------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | `bytes` is borrowed here
| returns a value referencing data owned by the current function
My knowledge of Rust's borrow-checking is still fledgling so I would appreciate if someone could help me figure out what's the right way to build KesSecretKey
The text was updated successfully, but these errors were encountered:
I am trying to reconstruct a
KesSecretKey
from a base64-encoded string coming from a JSON structure that's generated in Haskell, for the purpose of testing header validation logic. Here is the code I am using:which fails to compile because of
My knowledge of Rust's borrow-checking is still fledgling so I would appreciate if someone could help me figure out what's the right way to build
KesSecretKey
The text was updated successfully, but these errors were encountered: