Skip to main content

Emitter

Struct Emitter 

Source
pub struct Emitter { /* private fields */ }
Expand description

Emits Events to core (NDJSON mode) or renders them for a human (standalone mode).

Construct with Emitter::from_env. The mode is chosen by protocol_mode; callers write the same code either way.

Implementations§

Source§

impl Emitter

Source

pub fn from_env() -> Self

Source

pub fn log(&self, level: LogLevel, msg: impl Into<String>)

Source

pub fn info(&self, msg: impl Into<String>)

Source

pub fn warn(&self, msg: impl Into<String>)

Source

pub fn error(&self, msg: impl Into<String>)

Source

pub fn progress(&self, done: u64, total: Option<u64>, msg: impl Into<String>)

Source

pub fn note(&self, relpath: impl Into<String>, action: NoteAction)

Announce a note at relpath (relative to the vault root) so core can index it. Prefer Emitter::write_note, which writes the file and emits this for you.

Source

pub fn result_ok(&self, summary: Value)

Terminal success event with a JSON summary.

Source

pub fn result_ok_no_index(&self, summary: Value)

Terminal success event that tells core not to index afterwards (e.g. --dry-run).

Source

pub fn result_err(&self, summary: Value)

Terminal failure event.

Source

pub fn write_note(&self, relpath: &str, body: &str) -> Result<PathBuf>

Write a Markdown note into the vault and emit the matching Event::Note.

Guards (contract): relpath must end in .md and must not escape the vault root. Parent directories are created. Returns the absolute path written.

Source

pub fn append_note(&self, relpath: &str, body: &str) -> Result<PathBuf>

Append to (or create) a Markdown note and emit NoteAction::Append.

Trait Implementations§

Source§

impl Default for Emitter

Source§

fn default() -> Self

Returns the “default value” for a type. 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, 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.