diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2021-04-02 15:47:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-02 09:47:57 -0400 |
commit | 058579da562989ed15c86598053644bbc86c6747 (patch) | |
tree | 7f0f2bf30684dcbb350b93d987771f17a4abd250 /op_crates/crypto/lib.rs | |
parent | adf57610904cb4f4ef25fb077f6e39c9017a4ea9 (diff) |
refactor(ops): remove variadic buffers (#9944)
Diffstat (limited to 'op_crates/crypto/lib.rs')
-rw-r--r-- | op_crates/crypto/lib.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/op_crates/crypto/lib.rs b/op_crates/crypto/lib.rs index b8fe3fefb..9fc61d871 100644 --- a/op_crates/crypto/lib.rs +++ b/op_crates/crypto/lib.rs @@ -2,6 +2,7 @@ #![deny(warnings)] +use deno_core::error::null_opbuf; use deno_core::error::AnyError; use deno_core::serde_json::json; use deno_core::serde_json::Value; @@ -29,15 +30,15 @@ pub fn init(isolate: &mut JsRuntime) { pub fn op_crypto_get_random_values( state: &mut OpState, _args: Value, - zero_copy: &mut [ZeroCopyBuf], + zero_copy: Option<ZeroCopyBuf>, ) -> Result<Value, AnyError> { - assert_eq!(zero_copy.len(), 1); + let mut zero_copy = zero_copy.ok_or_else(null_opbuf)?; let maybe_seeded_rng = state.try_borrow_mut::<StdRng>(); if let Some(seeded_rng) = maybe_seeded_rng { - seeded_rng.fill(&mut *zero_copy[0]); + seeded_rng.fill(&mut *zero_copy); } else { let mut rng = thread_rng(); - rng.fill(&mut *zero_copy[0]); + rng.fill(&mut *zero_copy); } Ok(json!({})) |