Skip to main content

MacroContext

Struct MacroContext 

Source
pub struct MacroContext<'call> { /* private fields */ }
Expand description

Capability token for a genuine macro/command callback.

It is callback-borrowed and must not be retained or sent to another thread. The ordinary build exposes no xlcOnTime scheduling operation:

ⓘ
use excel_api::MacroContext;

fn no_production_ontime(context: &MacroContext<'_>) {
    let _ = context.experimental_schedule_on_time(45_000.0, "COMMAND");
}

Implementations§

Source§

impl MacroContext<'_>

Source

pub fn drain_dispatcher(&self) -> DispatchDrainReport

Drains one bounded cooperative batch under this genuine macro callback.

Enqueueing a request does not invoke this method or otherwise wake Excel.

Source§

impl<'call> MacroContext<'call>

Source

pub fn active_sheet_id(&self) -> Result<u64, ExcelCallError>

Returns the internal ID of Excel’s active/front sheet.

This is deliberately not named “current”: the zero-argument xlSheetId contract identifies the active/front sheet.

Source

pub fn current_sheet_name(&self) -> Result<ExcelString, ExcelCallError>

Returns the name of the current sheet, not the active sheet.

Source§

impl<'call> MacroContext<'call>

Source

pub fn is_cancellation_requested(&self) -> Result<bool, ExcelCallError>

Poll whether Excel has received a user cancellation/break request. This zero-argument form preserves a pending break request.

Source

pub fn is_cancellation_requested_with( &self, mode: AbortCheckMode, ) -> Result<bool, ExcelCallError>

Poll cancellation while explicitly preserving or clearing a pending break.

Source§

impl<'call> MacroContext<'call>

Source

pub fn caller(&self) -> Result<ExcelOwnedValue<'call>, ExcelCallError>

Returns Excel’s caller value with its Excel-owned result lifetime.

Source§

impl<'call> MacroContext<'call>

Source

pub fn coerce( &self, source: &ExcelOwnedValue<'call>, target: CoerceTarget, ) -> Result<ExcelOwnedValue<'call>, ExcelCallError>

Converts an Excel-owned callback result to a requested root type.

The source remains owned by the caller and is not consumed or released by xlCoerce; the returned root has its own xlFree obligation encoded in ExcelOwnedValue.

Trait Implementations§

Source§

impl<'call> Debug for MacroContext<'call>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'call> !RefUnwindSafe for MacroContext<'call>

§

impl<'call> !UnwindSafe for MacroContext<'call>

§

impl<'call> Freeze for MacroContext<'call>

§

impl<'call> Send for MacroContext<'call>

§

impl<'call> Sync for MacroContext<'call>

§

impl<'call> Unpin for MacroContext<'call>

§

impl<'call> UnsafeUnpin for MacroContext<'call>

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.