Sheet

Struct Sheet 

Source
pub struct Sheet {
    pub locator: Arc<Reference>,
    pub path: Arc<str>,
    pub date: DateTime,
    pub version: u32,
    pub minor_version: u32,
    pub first_version: u32,
    pub latest_version: u32,
    pub model: Arc<str>,
    pub pattern: Arc<str>,
    pub length: u32,
}

Fields§

§locator: Arc<Reference>§path: Arc<str>§date: DateTime§version: u32§minor_version: u32§first_version: u32§latest_version: u32§model: Arc<str>§pattern: Arc<str>§length: u32

Implementations§

Source§

impl Sheet

Source

pub fn convert(node: &Node) -> Result<Self>

§Converts a workflow node into a sheet representation containing metadata about the workflow and its inference configuration.
§title: Convert

Converts a workflow node into a sheet representation containing metadata about the workflow and its inference configuration.

This function extracts comprehensive metadata from a Node and creates a Sheet that provides a structured view of the workflow’s state, versioning information, and inference characteristics. The sheet serves as a snapshot of the workflow’s current state for inspection, debugging, or API responses.

§Arguments
  • node - A reference to a Node containing the workflow to convert. The node must be initialized and contain a loaded workflow.
§Returns

Returns a Result<Sheet> containing a Sheet instance populated with:

  • Locator: The global reference that uniquely identifies this workflow
  • Path: File system path to the workflow’s .aim file
  • Date: Timestamp of the workflow version
  • Version: Major version (epoch) number
  • Minor Version: Minor version (partial) number
  • First Version: The first version epoch in the journal
  • Latest Version: The most recent version epoch in the journal
  • Model: The inference model type as a string
  • Pattern: The inference pattern type as a string
  • Length: Total number of rows in the workflow
§Errors

Returns an error if:

  • The node is not initialized (in Pending state)
  • The workflow cannot be loaded from the node
  • Any underlying I/O operations fail during workflow loading
§Behavior

Internally, convert() performs the following operations:

  1. Load Workflow: Calls node.get_workflow()? to ensure the workflow is loaded and accessible
  2. Extract Metadata: Retrieves all workflow metadata through the WorkflowLike trait methods
  3. Path Conversion: Converts the workflow path to a string representation
  4. Inference Information: Extracts model and pattern information from the node’s inference configuration
  5. Row Count: Gets the total number of rows in the workflow
  6. Construct Sheet: Creates and returns a new Sheet instance with all extracted data
§Side Effects
  • Workflow Loading: If the node was in an unloaded state, this function triggers loading of the workflow from disk
  • Reference Sharing: The returned sheet shares references to the node’s locator and inference configuration
§Usage Pattern

This example shows how to convert a node to a sheet for metadata inspection:

use aimx::{values::Node, Sheet, Reference};

// Assuming you have a Node instance (typically obtained through the API)
// let node = /* obtain node from workflow */;

// Convert to sheet for inspection
// let sheet = Sheet::convert(&node)?;

// Access workflow metadata
// println!("Workflow: {}", sheet.locator());
// println!("Version: {}.{}", sheet.version(), sheet.minor_version());
// println!("Model: {}", sheet.model());
// println!("Pattern: {}", sheet.pattern());
// println!("Rows: {}", sheet.length());
§See Also
Source

pub fn locator(&self) -> &Arc<Reference>

Source

pub fn path(&self) -> &Arc<str>

Source

pub fn date(&self) -> &DateTime

Source

pub fn version(&self) -> u32

Source

pub fn minor_version(&self) -> u32

Source

pub fn first_version(&self) -> u32

Source

pub fn latest_version(&self) -> u32

Source

pub fn model(&self) -> &Arc<str>

Source

pub fn pattern(&self) -> &Arc<str>

Source

pub fn length(&self) -> u32

Source

pub fn is_empty(&self) -> bool

Source

pub fn print(&self, writer: &mut Writer)

§Serializes a Sheet instance to a Writer, outputting structured metadata about a workflow.
§title: Print

This function serializes a Sheet instance to a Writer, outputting structured metadata about a workflow in a human-readable format.

§Arguments
  • writer - A mutable reference to Writer that receives the serialized output. The writer handles formatting and buffering of the output.
§Behavior

Internally, print() performs the following operations:

  1. Writes a start marker "=== SHEET START ===" followed by a newline
  2. Serializes each field of the Sheet with descriptive labels:
    • locator: The workflow reference path using dot notation
    • path: The filesystem path to the workflow file
    • date: The workflow creation/modification date in ISO format
    • version: The current version number
    • minor_version: The minor version number
    • first_version: The first version number in the workflow history
    • latest_version: The latest version number in the workflow history
    • model: The inference model identifier
    • pattern: The inference pattern identifier
    • length: The number of rows in the workflow
  3. Writes an end marker "=== SHEET END ===" followed by a newline

Each field is written on its own line with the format "- field_name: value".

§Side Effects
  • Writes structured text data to the provided Writer instance
  • No file I/O operations are performed directly by this function
§Usage Pattern
use aimx::{Sheet, Reference, aim::Writer};

// Example of how to use print() with a mock Sheet
fn example_usage() {
    // Create a mock sheet (in real usage, this would come from a workflow)
    let locator = Reference::workspace();
    let sheet = Sheet {
        locator,
        path: "workspace/foo.aim".into(),
        date: jiff::civil::DateTime::new(2023, 1, 1, 0, 0, 0, 0).unwrap(),
        version: 1,
        minor_version: 0,
        first_version: 1,
        latest_version: 1,
        model: "gpt-4".into(),
        pattern: "evaluation".into(),
        length: 5,
    };

    // Create a writer for output
    let mut writer = Writer::formulizer();

    // Serialize the sheet to the writer
    sheet.print(&mut writer);

    // Get the formatted output
    let output = writer.finish();
    println!("{}", output);
}
§See Also
Source

pub fn to_formula(&self) -> String

§Return the formula-string representation (round-trippable by the parser).
§title: to_formula

This function returns a formula-string representation of a Sheet instance that is round-trippable by the parser. The output is formatted using the formulizer writer mode, which applies quote escaping to ensure the string can be safely parsed back into the original structure.

§Returns

Returns a String containing the formula representation of the Sheet, with all text values properly quoted and escaped for safe parsing.

§Behavior

Internally, to_formula() performs the following operations:

  1. Creates a new Writer instance using Writer::formulizer() which sets up quote escaping mode
  2. Calls self.print(&mut writer) to serialize the Sheet’s metadata to the writer
  3. Calls writer.finish() to extract the final string representation

The formulizer mode ensures that:

  • All text values are wrapped in single quotes
  • Special characters within quoted strings are properly escaped
  • The output format is consistent and parseable by the AIMX parser
§Side Effects

This function has no side effects. It only reads the Sheet’s data and returns a formatted string representation.

§Usage Pattern
use aimx::{Aim, Sheet, Reference};
use std::sync::Arc;

// Get a sheet from the API
let reference = Reference::parse("workflow.name").unwrap();
let sheet = Aim::sheet(reference).unwrap();

// Convert to formula representation
let formula = sheet.to_formula();
println!("Formula: {}", formula);
§See Also
Source

pub fn custom_format_date(&self, format: &str) -> String

Formats the Sheet’s date using the computer’s local timezone with a custom format string.

§Arguments
  • format - A strftime-style format string (e.g., “%Y/%m/%d”, “%A, %B %d, %Y”)
§Returns

Returns a Result<String> containing the formatted date string.

§Examples
use aimx::{Sheet, values::Node};
 
// Assuming you have a Node instance
// let node = /* obtain node from workflow */;
// let sheet = Sheet::convert(&node)?;
// let formatted = sheet.custom_format_date("%Y-%m-%d");
// let formatted = sheet.custom_format_date("%A, %B %d, %Y at %I:%M %p");
Source

pub fn format_date(&self) -> String

Formats the Sheet’s date using the computer’s local timezone with a default presentable format.

The default format is: “Weekday, DD/MM/YY HH:MM AM/PM” For example: “Monday, 15/3/24 02:30 PM”

§Returns

Returns a Result<String> containing the formatted date string.

§Examples
use aimx::{Sheet, values::Node};
 
// Assuming you have a Node instance
// let node = /* obtain node from workflow */;
// let sheet = Sheet::convert(&node)?;
// let formatted = sheet.format_date();
// Output: "Monday, 15/3/24 02:30 PM"

Trait Implementations§

Source§

impl Clone for Sheet

Source§

fn clone(&self) -> Sheet

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Sheet

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for Sheet

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Sheet

Source§

fn eq(&self, other: &Sheet) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl WriterLike for Sheet

Source§

fn write(&self, writer: &mut Writer)

Serialize this expression with the given Writer.
Source§

fn to_stringized(&self) -> String

Return a string representation (raw unsafe output).
Source§

fn to_sanitized(&self) -> String

Return a sanitized string representation (escaped for safe output).
Source§

fn to_expressionized(&self) -> String

Return a sanitized string representation (escaped for safe output).
Source§

impl StructuralPartialEq for Sheet

Auto Trait Implementations§

§

impl Freeze for Sheet

§

impl RefUnwindSafe for Sheet

§

impl Send for Sheet

§

impl Sync for Sheet

§

impl Unpin for Sheet

§

impl UnwindSafe for Sheet

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

impl<T> ToStringFallible for T
where T: Display,

§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,