Struct eszip::v2::EszipV2

source ·
pub struct EszipV2 { /* private fields */ }
Expand description

Version 2 of the Eszip format. This format supports streaming sources and source maps.

Implementations§

source§

impl EszipV2

source

pub fn has_magic(buffer: &[u8]) -> bool

source

pub async fn parse<R: AsyncRead + Unpin>( reader: BufReader<R> ) -> Result<(EszipV2, impl Future<Output = Result<BufReader<R>, ParseError>>), ParseError>

Parse a EszipV2 from an AsyncRead stream. This function returns once the header section of the eszip has been parsed. Once this function returns, the data section will not necessarially have been parsed yet. To parse the data section, poll/await the future returned in the second tuple slot.

source

pub fn add_import_map( &mut self, kind: ModuleKind, specifier: String, source: Arc<[u8]> )

Add an import map to the eszip archive. The import map will always be placed at the top of the archive, so it can be read before any other modules are loaded.

If a module with this specifier is already present, then this is a no-op (except that this specifier will now be at the top of the archive).

source

pub fn add_opaque_data(&mut self, specifier: String, data: Arc<[u8]>)

Add an opaque data to the eszip.

source

pub fn add_npm_snapshot( &mut self, snapshot: ValidSerializedNpmResolutionSnapshot )

Adds an npm resolution snapshot to the eszip.

source

pub fn take_npm_snapshot( &mut self ) -> Option<ValidSerializedNpmResolutionSnapshot>

Takes an npm resolution snapshot from the eszip.

source

pub fn into_bytes(self) -> Vec<u8>

Serialize the eszip archive into a byte buffer.

source

pub fn from_graph( graph: ModuleGraph, parser: &CapturingModuleParser<'_>, emit_options: EmitOptions ) -> Result<Self, Error>

Turn a deno_graph::ModuleGraph into an EszipV2. All modules from the graph will be transpiled and stored in the eszip archive.

The ordering of the modules in the graph is dependant on the module graph tree. The root module is added to the top of the archive, and the leaves to the end. This allows for efficient deserialization of the archive right into an isolate.

source

pub fn get_module(&self, specifier: &str) -> Option<Module>

Get the module metadata for a given module specifier. This function will follow redirects. The returned module has functions that can be used to obtain the module source and source map. The module returned from this function is guaranteed to be a valid module, which can be loaded into v8.

Note that this function should be used to obtain a module; if you wish to get an import map, use get_import_map instead.

source

pub fn get_import_map(&self, specifier: &str) -> Option<Module>

Get the import map for a given specifier.

Note that this function should be used to obtain an import map; the returned “Module” is not necessarily a valid module that can be loaded into v8 (in other words, JSONC may be returned). If you wish to get a valid module, use get_module instead.

source

pub fn specifiers(&self) -> Vec<String>

Returns a list of all the module specifiers in this eszip archive.

Trait Implementations§

source§

impl Debug for EszipV2

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for EszipV2

source§

fn default() -> EszipV2

Returns the “default value” for a type. Read more
source§

impl IntoIterator for EszipV2

Get an iterator over all the modules (including an import map, if any) in this eszip archive.

Note that the iterator will iterate over the specifiers’ “snapshot” of the archive. If a new module is added to the archive after the iterator is created via into_iter(), that module will not be iterated over.

§

type Item = (String, Module)

The type of the elements being iterated over.
§

type IntoIter = IntoIter<<EszipV2 as IntoIterator>::Item>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> Send for T
where T: ?Sized,

§

impl<T> Sync for T
where T: ?Sized,