Skip to main content

MicroExt

Trait MicroExt 

Source
pub trait MicroExt {
    // Required methods
    fn append_micro(
        &mut self,
        registry: &MicroRegistry,
        name: &str,
    ) -> Result<&mut Self, MicroError>;
    fn append_micro_asset(&mut self, asset: &MicroAsset) -> &mut Self;
    fn expand_micro(&mut self, registry: &MicroRegistry) -> Vec<Diagnostic>;
}
Expand description

Micro assets on Text.

use rich::Text;
use rich_micro::{Layer, MicroAsset, MicroExt, MicroRegistry};

let mut registry = MicroRegistry::new();
registry.add(Layer::Inline, MicroAsset::new("ship", "rocket")?.with_emoji("🚀")?)?;
let mut text = Text::new("Deploying ");
text.append_micro(&registry, "ship")?;
assert_eq!(text.plain(), "Deploying 🚀");
assert_eq!(text.cell_len(), 12);

Required Methods§

Source

fn append_micro( &mut self, registry: &MicroRegistry, name: &str, ) -> Result<&mut Self, MicroError>

Append the asset name resolves to, as its placeholder cells.

Source

fn append_micro_asset(&mut self, asset: &MicroAsset) -> &mut Self

Append asset’s placeholder cells.

Source

fn expand_micro(&mut self, registry: &MicroRegistry) -> Vec<Diagnostic>

Replace the :micro:name: tokens in this text (see markup for when to prefer the markup path).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl MicroExt for Text

Source§

fn append_micro( &mut self, registry: &MicroRegistry, name: &str, ) -> Result<&mut Self, MicroError>

Source§

fn append_micro_asset(&mut self, asset: &MicroAsset) -> &mut Self

Source§

fn expand_micro(&mut self, registry: &MicroRegistry) -> Vec<Diagnostic>

Implementors§