Skip to main content

AsyncHighlighter

Struct AsyncHighlighter 

Source
pub struct AsyncHighlighter<P: GrammarProvider> { /* private fields */ }
Expand description

Asynchronous highlighter for WASM/browser contexts.

Uses an async provider where get() may need to load plugins.

§Example

use arborium_highlight::{AsyncHighlighter, WasmPluginProvider};

let mut highlighter = AsyncHighlighter::new(WasmPluginProvider::new());
let html = highlighter.highlight("rust", "fn main() {}").await?;

Implementations§

Source§

impl<P: GrammarProvider> AsyncHighlighter<P>

Source

pub fn new(provider: P) -> Self

Create a new asynchronous highlighter with default configuration.

Source

pub fn with_config(provider: P, config: HighlightConfig) -> Self

Create a new asynchronous highlighter with custom configuration.

Source

pub fn provider_mut(&mut self) -> &mut P

Get a mutable reference to the underlying provider.

Source

pub async fn highlight( &mut self, language: &str, source: &str, ) -> Result<String, HighlightError>

Highlight source code asynchronously.

Auto Trait Implementations§

§

impl<P> Freeze for AsyncHighlighter<P>
where P: Freeze,

§

impl<P> RefUnwindSafe for AsyncHighlighter<P>
where P: RefUnwindSafe,

§

impl<P> Send for AsyncHighlighter<P>
where P: Send,

§

impl<P> Sync for AsyncHighlighter<P>
where P: Sync,

§

impl<P> Unpin for AsyncHighlighter<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for AsyncHighlighter<P>
where P: UnsafeUnpin,

§

impl<P> UnwindSafe for AsyncHighlighter<P>
where P: UnwindSafe,

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.