Skip to content

Commit

Permalink
doc: improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Valerioageno committed Sep 7, 2024
1 parent 90c2d74 commit 697d569
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/ssr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use std::collections::HashMap;
use std::fmt;

/// This enum holds all the possible Ssr error states.
#[derive(Debug, PartialEq, Eq)]
pub enum SsrError {
InvalidJs(&'static str),
Expand All @@ -15,6 +16,9 @@ impl fmt::Display for SsrError {
}
}

/// This struct holds all the necessary v8 utilities to
/// execute Javascript code.
/// It cannot be shared across threads.
#[derive(Debug)]
pub struct Ssr<'s, 'i> {
isolate: *mut v8::OwnedIsolate,
Expand All @@ -40,22 +44,20 @@ where
{
/// Initialize a V8 js engine instance. It's mandatory to call it before
/// any call to V8. The Ssr module needs this function call before any other
/// operation.
/// operation. It cannot be called more than once per process.
pub fn create_platform() {
let platform = v8::new_default_platform(0, false).make_shared();
v8::V8::initialize_platform(platform);
v8::V8::initialize();
}

/// It creates a new SSR instance.
/// It creates a new SSR instance (multiple instances are allowed).
///
/// This function is expensive and it should be called as less as possible.
///
/// Even though V8 allows multiple threads the Ssr struct created with this call can be accessed by just
/// the thread that created it.
///
/// Multiple instances are allowed.
///
/// Entry point is the JS element that the bundler exposes. It has to be an empty string in
/// case the bundle is exported as IIFE.
///
Expand Down

0 comments on commit 697d569

Please sign in to comment.