Skip to content
Symi Docs
Rust

The Rust manual covers the recommended facade. The complete native crate is documented in the native Rust API reference.

On this page

Serialization and output

Serialization is a lossless interchange format for supported mathematical objects. Rendering is a presentation operation and does not change the object.

Output and serialization#

to_latex#

api::Session method

pub fn to_latex(&self, target: &Expression) -> Result<String, ApiError>
Calling forms and variants

api::Expression method: api::Expression::to_latex

pub fn to_latex(&self) -> Result<String, ApiError>

Variant for this object — api::Circle2d method: api::Circle2d::to_latex

pub fn to_latex(&self) -> Result<String, ApiError>

Variant for this object — api::Point2d method: api::Point2d::to_latex

pub fn to_latex(&self) -> Result<String, ApiError>

Variant for this object — api::Polygon2d method: api::Polygon2d::to_latex

pub fn to_latex(&self) -> Result<String, ApiError>

Variant for this object — api::Segment2d method: api::Segment2d::to_latex

pub fn to_latex(&self) -> Result<String, ApiError>

Variant for this object — api::geometry_operations::Triangle2d method: api::geometry_operations::Triangle2d::to_latex

pub fn to_latex(&self) -> Result<String, ApiError>

Variant for this object — api::serialization::Matrix method: api::serialization::Matrix::to_latex

pub fn to_latex(&self) -> Result<String, ApiError>

Render an expression as LaTeX. Matrices and geometry objects have their own to_latex methods.

to_latex_with_options#

api::serialization::Session method

pub fn to_latex_with_options(
    &self,
    input_expression: &Expression,
    options: LatexPresentationOptions,
) -> Result<String, ApiError>
Calling forms

api::serialization::Expression method: api::serialization::Expression::to_latex_with_options

pub fn to_latex_with_options(
    &self,
    options: LatexPresentationOptions,
) -> Result<String, ApiError>

Render an expression as LaTeX with presentation flags. Each argument is a string naming the choice for one flag; an unrecognized name falls back to that flag's canonical default (so to_latex_with_options(e, "", "", "") equals to_latex(e)):

  • exponential_style: "exp_function" (default, \exp(u)) or "e_caret" (e^{u}, the form the LaTeX parser reads back as exponentiation).
  • natural_logarithm_style: "log" (default, \log) or "ln" (\ln).
  • multiletter_symbol_style: "italic" (default, \mathit{name}) or "upright" (\mathrm{name}).

The defaults are fixed, content-independent canonical choices. Readability heuristics (for example, switching a tall exponent to \exp) belong in the caller, via the render-twice pattern: render with the default, test the result, and re-render with the other flag value if it violates the heuristic.

serialize_object#

api::serialization::Session method

pub fn serialize_object(
    &self,
    object: &MathematicalObject,
) -> Result<String, ApiError>
Calling forms and variants

api::serialization::Expression method: api::serialization::Expression::serialize_object

pub fn serialize_object(&self) -> Result<String, ApiError>

Variant for this object — api::serialization::Circle2d method: api::serialization::Circle2d::serialize_object

pub fn serialize_object(&self) -> Result<String, ApiError>

Variant for this object — api::serialization::Matrix method: api::serialization::Matrix::serialize_object

pub fn serialize_object(&self) -> Result<String, ApiError>

Variant for this object — api::serialization::Point2d method: api::serialization::Point2d::serialize_object

pub fn serialize_object(&self) -> Result<String, ApiError>

Variant for this object — api::serialization::Polygon2d method: api::serialization::Polygon2d::serialize_object

pub fn serialize_object(&self) -> Result<String, ApiError>

Variant for this object — api::serialization::Segment2d method: api::serialization::Segment2d::serialize_object

pub fn serialize_object(&self) -> Result<String, ApiError>

Variant for this object — api::serialization::Triangle2d method: api::serialization::Triangle2d::serialize_object

pub fn serialize_object(&self) -> Result<String, ApiError>

Serialize an expression, matrix, or geometry object to the stable Symi serialization format, round-trippable via parse_serialized_object.

Notes: in WASM this is a per-object method because a single polymorphic context method cannot downcast a JsValue back to an exported Rust type.

parse_serialized_object#

api::serialization::Session method

pub fn parse_serialized_object(
    &self,
    text: &str,
) -> Result<MathematicalObject, ApiError>

Inverse of serialize_object; returns the matching surface class.

Example#

This family is not part of the recommended symi::api facade in this release. Call it through the native modules in the native Rust API reference.

Additional API#

api::serialization#

api module

pub mod serialization;

Serialization, parsing, and presentation operations of the native API.

ExponentialPresentation#

Type

pub enum ExponentialPresentation

How an exponential is rendered.

ExponentialPresentation.ECaret#

api::serialization::ExponentialPresentation variant

ECaret,

Render as a power of e.

ExponentialPresentation.ExpFunction#

api::serialization::ExponentialPresentation variant

ExpFunction,

Render as the exp function.

LatexPresentationOptions#

api re_export

pub use serialization::LatexPresentationOptions;

Presentation choices applied when rendering an expression as LaTeX.

Calling forms

Type: api::serialization::LatexPresentationOptions

pub struct LatexPresentationOptions

LatexPresentationOptions.from_style_names#

api::serialization::LatexPresentationOptions method

pub fn from_style_names(
    exponential_style: &str,
    natural_logarithm_style: &str,
    multiletter_symbol_style: &str,
) -> Self

Build presentation options from the stable style spellings used by every binding.

MathematicalObject#

api re_export

pub use serialization::MathematicalObject;

Any top-level mathematical object a session can serialize or reconstruct.

Calling forms

Type: api::serialization::MathematicalObject

pub enum MathematicalObject

MathematicalObject.Circle#

api::serialization::MathematicalObject variant

Circle(Circle2d)

A circle circumference.

MathematicalObject.DiophantineSolution#

api::serialization::MathematicalObject variant

DiophantineSolution(String)

A Diophantine solution family, carried in its lossless serialized text.

MathematicalObject.Expression#

api::serialization::MathematicalObject variant

Expression(Expression)

An interned expression.

MathematicalObject.Matrix#

api::serialization::MathematicalObject variant

Matrix(Matrix)

A matrix.

MathematicalObject.PartialDifferentialEquation#

api::serialization::MathematicalObject variant

PartialDifferentialEquation(crate::api::PartialDifferentialEquationProblem)

A validated scalar partial differential equation problem.

MathematicalObject.Point#

api::serialization::MathematicalObject variant

Point(Point2d)

A point.

MathematicalObject.Polygon#

api::serialization::MathematicalObject variant

Polygon(Polygon2d)

A polygon boundary.

MathematicalObject.Segment#

api::serialization::MathematicalObject variant

Segment(Segment2d)

A closed segment.

MathematicalObject.Triangle#

api::serialization::MathematicalObject variant

Triangle(Triangle2d)

A triangle boundary.

MultiletterSymbolPresentation#

Type

pub enum MultiletterSymbolPresentation

How a multiple-letter symbol name is rendered.

MultiletterSymbolPresentation.Italic#

api::serialization::MultiletterSymbolPresentation variant

Italic,

Render in italic.

MultiletterSymbolPresentation.Upright#

api::serialization::MultiletterSymbolPresentation variant

Upright,

Render upright.

NaturalLogarithmPresentation#

Type

pub enum NaturalLogarithmPresentation

How the natural logarithm is rendered.

NaturalLogarithmPresentation.Ln#

api::serialization::NaturalLogarithmPresentation variant

Ln,

Render as ln.

NaturalLogarithmPresentation.Log#

api::serialization::NaturalLogarithmPresentation variant

Log,

Render as log.