[][src]Struct sourcemap::SourceMapIndex

pub struct SourceMapIndex { /* fields omitted */ }

Represents a sourcemap index in memory

Implementations

impl SourceMapIndex[src]

pub fn from_reader<R: Read>(rdr: R) -> Result<SourceMapIndex>[src]

Creates a sourcemap index from a reader over a JSON stream in UTF-8 format. Optionally a "garbage header" as defined by the sourcemap draft specification is supported. In case a regular sourcemap is encountered an error is returned.

pub fn to_writer<W: Write>(&self, w: W) -> Result<()>[src]

Writes a sourcemap index into a writer.

pub fn from_slice(slice: &[u8]) -> Result<SourceMapIndex>[src]

Creates a sourcemap index from a reader over a JSON byte slice in UTF-8 format. Optionally a "garbage header" as defined by the sourcemap draft specification is supported. In case a regular sourcemap is encountered an error is returned.

pub fn new(
    file: Option<String>,
    sections: Vec<SourceMapSection>
) -> SourceMapIndex
[src]

Constructs a new sourcemap index from raw components.

  • file: an optional filename of the index
  • sections: a vector of source map index sections

pub fn new_ram_bundle_compatible(
    file: Option<String>,
    sections: Vec<SourceMapSection>,
    x_facebook_offsets: Option<Vec<Option<u32>>>,
    x_metro_module_paths: Option<Vec<String>>
) -> SourceMapIndex
[src]

Constructs a new sourcemap index from raw components including the facebook RAM bundle extensions.

  • file: an optional filename of the index
  • sections: a vector of source map index sections
  • x_facebook_offsets: a vector of facebook offsets
  • x_metro_module_paths: a vector of metro module paths

pub fn get_file(&self) -> Option<&str>[src]

Returns the embedded filename in case there is one.

pub fn set_file(&mut self, value: Option<&str>)[src]

Sets a new value for the file.

pub fn get_section_count(&self) -> u32[src]

Returns the number of sections in this index

pub fn get_section(&self, idx: u32) -> Option<&SourceMapSection>[src]

Looks up a single section and returns it

pub fn get_section_mut(&mut self, idx: u32) -> Option<&mut SourceMapSection>[src]

Looks up a single section and returns it as a mutable ref

pub fn sections(&self) -> SourceMapSectionIter

Important traits for SourceMapSectionIter<'a>

impl<'a> Iterator for SourceMapSectionIter<'a> type Item = &'a SourceMapSection;
[src]

Iterates over all sections

pub fn get_original_function_name<'a>(
    &self,
    line: u32,
    col: u32,
    minified_name: &str,
    sv: &'a SourceView<'a>
) -> Option<&str>
[src]

Given a location, name and minified source file resolve a minified name to an original function name.

This invokes some guesswork and requires access to the original minified source. This will not yield proper results for anonymous functions or functions that do not have clear function names. (For instance it's recommended that dotted function names are not passed to this function).

pub fn lookup_token(&self, line: u32, col: u32) -> Option<Token>[src]

Looks up the closest token to a given line and column.

This requires that the referenced sourcemaps are actually loaded. If a sourcemap is encountered that is not embedded but just externally referenced it is silently skipped.

pub fn flatten(&self) -> Result<SourceMap>[src]

Flattens an indexed sourcemap into a regular one. This requires that all referenced sourcemaps are attached.

pub fn flatten_and_rewrite(self, options: &RewriteOptions) -> Result<SourceMap>[src]

Flattens an indexed sourcemap into a regular one and automatically rewrites it. This is more useful than plain flattening as this will cause the sourcemap to be properly deduplicated.

pub fn is_for_ram_bundle(&self) -> bool[src]

Returns true if this sourcemap is for a RAM bundle.

pub fn x_facebook_offsets(&self) -> Option<&[Option<u32>]>[src]

Returns embeded x-facebook-offset values.

pub fn x_metro_module_paths(&self) -> Option<&[String]>[src]

Returns embedded metro module paths.

Trait Implementations

impl Clone for SourceMapIndex[src]

impl Debug for SourceMapIndex[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.