Skip to content

Commit

Permalink
improve internal documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rscarson committed Jul 9, 2024
1 parent c16750e commit 55779e1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/js_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ macro_rules! impl_v8 {
}

/// A trait that is used to check if a `v8::Value` is of a certain type
/// Will cause a panic if validate is insufficient to verify that the
/// given value is of type `T::Output`
trait V8TypeChecker {
type Output;

Expand Down Expand Up @@ -98,7 +100,7 @@ impl V8TypeChecker for DefaultTypeChecker {

/// The core struct behind the [Function], [Promise], and [Value] types
/// Should probably not be user-facing
/// TODO: Better API for this so we can make it public eventually
/// TODO: Safer API for this so we can make it public eventually
///
/// A Deserializable javascript object, that can be stored and used later
/// Must live as long as the runtime it was birthed from
Expand All @@ -109,6 +111,7 @@ struct V8Value<V8TypeChecker>(
);

impl<T: V8TypeChecker> V8Value<T> {
/// Returns the underlying global as a local in the type configured by the type checker
pub(crate) fn as_local<'a>(&self, scope: &mut HandleScope<'a>) -> v8::Local<'a, T::Output>
where
v8::Local<'a, T::Output>: TryFrom<v8::Local<'a, v8::Value>>,
Expand All @@ -119,6 +122,7 @@ impl<T: V8TypeChecker> V8Value<T> {
.expect("Failed to convert V8Value: Invalid V8TypeChecker!")
}

/// Returns the underlying global in the type configured by the type checker
pub(crate) fn as_global<'a>(&self, scope: &mut HandleScope<'a>) -> v8::Global<T::Output>
where
v8::Local<'a, T::Output>: TryFrom<v8::Local<'a, v8::Value>>,
Expand Down

0 comments on commit 55779e1

Please sign in to comment.