summaryrefslogtreecommitdiff
path: root/serde_v8/magic/value.rs
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2023-07-01 18:00:14 -0600
committerGitHub <noreply@github.com>2023-07-02 00:00:14 +0000
commite746b6d80654ba4e4e26370fe6e4f784ce841d92 (patch)
tree153ffad92a96126b9ab8e906dcdabf7648755931 /serde_v8/magic/value.rs
parentb9c0e7cd550ab14fa7da7e33ed87cbeeeb9785a0 (diff)
refactor(core): Extract deno_core (#19658)
`deno_core` is moving out! You'll find it at https://github.com/denoland/deno_core/ once this PR lands.
Diffstat (limited to 'serde_v8/magic/value.rs')
-rw-r--r--serde_v8/magic/value.rs48
1 files changed, 0 insertions, 48 deletions
diff --git a/serde_v8/magic/value.rs b/serde_v8/magic/value.rs
deleted file mode 100644
index 0333d75bc..000000000
--- a/serde_v8/magic/value.rs
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
-
-use crate::magic::transl8::impl_magic;
-use crate::magic::transl8::FromV8;
-use crate::magic::transl8::ToV8;
-use std::mem::transmute;
-
-/// serde_v8::Value allows passing through `v8::Value`s untouched
-/// when de/serializing & allows mixing rust & v8 values in structs, tuples...
-//
-// SAFETY: caveat emptor, the rust-compiler can no longer link lifetimes to their
-// original scope, you must take special care in ensuring your handles don't outlive their scope
-pub struct Value<'s> {
- pub v8_value: v8::Local<'s, v8::Value>,
-}
-impl_magic!(Value<'_>);
-
-impl<'s> From<v8::Local<'s, v8::Value>> for Value<'s> {
- fn from(v8_value: v8::Local<'s, v8::Value>) -> Self {
- Self { v8_value }
- }
-}
-
-impl<'s> From<Value<'s>> for v8::Local<'s, v8::Value> {
- fn from(v: Value<'s>) -> Self {
- v.v8_value
- }
-}
-
-impl ToV8 for Value<'_> {
- fn to_v8<'a>(
- &mut self,
- _scope: &mut v8::HandleScope<'a>,
- ) -> Result<v8::Local<'a, v8::Value>, crate::Error> {
- // SAFETY: not fully safe, since lifetimes are detached from original scope
- Ok(unsafe { transmute(self.v8_value) })
- }
-}
-
-impl FromV8 for Value<'_> {
- fn from_v8(
- _scope: &mut v8::HandleScope,
- value: v8::Local<v8::Value>,
- ) -> Result<Self, crate::Error> {
- // SAFETY: not fully safe, since lifetimes are detached from original scope
- Ok(unsafe { transmute::<Value, Value>(value.into()) })
- }
-}