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: u32Implementations§
Source§impl Sheet
impl Sheet
Sourcepub fn convert(node: &Node) -> Result<Self>
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 aNodecontaining 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
.aimfile - 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
Pendingstate) - The workflow cannot be loaded from the node
- Any underlying I/O operations fail during workflow loading
§Behavior
Internally, convert() performs the following operations:
- Load Workflow: Calls
node.get_workflow()?to ensure the workflow is loaded and accessible - Extract Metadata: Retrieves all workflow metadata through the
WorkflowLiketrait methods - Path Conversion: Converts the workflow path to a string representation
- Inference Information: Extracts model and pattern information from the node’s inference configuration
- Row Count: Gets the total number of rows in the workflow
- Construct Sheet: Creates and returns a new
Sheetinstance 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
Node- Workflow node handle with lazy loadingSheet- Structured workflow metadata representationWorkflowLike- Trait providing workflow metadata accesscrate::inference::Inference- Inference configuration with model and patternReference- Global workflow locator
pub fn locator(&self) -> &Arc<Reference>
pub fn path(&self) -> &Arc<str>
pub fn date(&self) -> &DateTime
pub fn version(&self) -> u32
pub fn minor_version(&self) -> u32
pub fn first_version(&self) -> u32
pub fn latest_version(&self) -> u32
pub fn model(&self) -> &Arc<str>
pub fn pattern(&self) -> &Arc<str>
pub fn length(&self) -> u32
pub fn is_empty(&self) -> bool
Sourcepub fn print(&self, writer: &mut Writer)
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 toWriterthat receives the serialized output. The writer handles formatting and buffering of the output.
§Behavior
Internally, print() performs the following operations:
- Writes a start marker
"=== SHEET START ==="followed by a newline - Serializes each field of the Sheet with descriptive labels:
locator: The workflow reference path using dot notationpath: The filesystem path to the workflow filedate: The workflow creation/modification date in ISO formatversion: The current version numberminor_version: The minor version numberfirst_version: The first version number in the workflow historylatest_version: The latest version number in the workflow historymodel: The inference model identifierpattern: The inference pattern identifierlength: The number of rows in the workflow
- 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
Sheet::to_formula()- Returns the formula-string representation using print()Writer- Buffered writer for AIM/AIMX data structuresReference::print()- Serializes references using dot notation
Sourcepub fn to_formula(&self) -> String
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:
- Creates a new
Writerinstance usingWriter::formulizer()which sets up quote escaping mode - Calls
self.print(&mut writer)to serialize the Sheet’s metadata to the writer - 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
Sheet::print()- Core serialization method used by this functionWriter::formulizer()- Writer factory method that provides quote escapingSheet::convert()- Creates a Sheet from a NodeReference::to_formula()- Similar functionality for Reference objects
Sourcepub fn custom_format_date(&self, format: &str) -> String
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");Sourcepub fn format_date(&self) -> String
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 WriterLike for Sheet
impl WriterLike for Sheet
Source§fn to_stringized(&self) -> String
fn to_stringized(&self) -> String
Source§fn to_sanitized(&self) -> String
fn to_sanitized(&self) -> String
Source§fn to_expressionized(&self) -> String
fn to_expressionized(&self) -> String
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.