Module foundations

Module foundations 

Source
Expand description

Foundational types and functions.

Modules§

calc
Calculations and processing of numeric values.
ops
Operations on values.
repr
Debug representation of values.
sys
System-related things.

Macros§

cast
Implements Reflect, FromValue, and IntoValue for a type.
eco_format
Create a new EcoString from a format string.
eco_vec
Create a new EcoVec with the given elements.

Structs§

Arg
An argument to a function call: 12 or draw: false.
Args
Captured arguments to a function.
Array
A sequence of values.
AutoValue
A value that indicates a smart default.
Binding
A bound value with metadata.
Bytes
A sequence of bytes.
Closure
A user-defined closure.
Content
A piece of document content.
ContentVtable
A vtable for performing element-specific actions on type-erased content. Also contains general metadata for the specific element.
Context
Data that is contextually made available to code.
ContextElem
Executes a context block.
Decimal
A fixed-point decimal number type.
Deprecation
Information about a deprecated binding.
Depth
A type that accumulates depth when folded.
Derived
A type that contains a user-visible source portion and something that is derived from it, but not user-visible.
Dict
A map from string keys to values.
DisplayPattern
A format in which a datetime can be displayed.
Duration
Represents a positive or negative span of time.
Dynamic
A value that is not part of the built-in enum.
Element
A document element.
Entries
An iterator over the entries in a style chain.
ExternalFieldData
Metadata for an ExternalField.
Field
An accessor for the I-th field of the element E. Values of this type are generated for each field of an element can be used to interact with this field programmatically, for example to access the style chain, as in styles.get(TextElem::size).
FieldVtable
A vtable for performing field-specific actions on type-erased content. Also contains general metadata for the specific field.
Func
A mapping from argument values to a return value.
IndexMap
A hash table where the iteration order of the key-value pairs is independent of the hash values of the keys.
Label
A label for an element.
LazyElementStore
Lazily initialized data for an element.
Links
An iterator over the links of a style chain.
LocatableSelector
A selector that can be used with query.
Module
A collection of variables and functions that are commonly related to a single theme.
NativeFuncData
Defines a native function.
NativeFuncPtr
A pointer to a native function’s implementation.
NativeRuleMap
Holds native show rules.
NativeShowRule
The show rule for a native element.
NativeTypeData
Defines a native type.
NoneValue
A value that indicates the absence of any other value.
OneOrMultiple
One element, or multiple provided as an array.
Packed
A packed element of a static type.
ParamInfo
Describes a function parameter.
PluginFunc
A function loaded from a WebAssembly plugin.
PositiveF64
A floating-point number that must be positive (strictly larger than zero).
Property
A style property originating from a set rule or constructor.
Recipe
A show rule recipe.
RecipeIndex
Identifies a show rule recipe from the top of the chain.
Regex
A regular expression.
RequiredFieldData
Metadata and routines for a RequiredField.
Scope
A map from binding names to values.
Scopes
A stack of scopes.
SequenceElem
A sequence of content.
Settable
A settable field of an element.
SettableFieldData
Metadata and routines for a SettableField.
SettablePropertyData
Metadata and routines for a SettableProperty.
ShowableSelector
A selector that can be used with show rules.
SmallVec
A Vec-like container that can store a small number of elements inline.
Str
A sequence of Unicode codepoints.
StyleChain
A chain of styles, similar to a linked list.
StyledElem
Content alongside styles.
Styles
A list of style properties.
Symbol
A Unicode symbol.
SymbolElem
A single character.
SymbolVariant
A value that can be cast to a symbol.
SynthesizedFieldData
Metadata and routines for a SynthesizedField.
TargetElem
This element exists solely to host the target style chain field. It is never constructed and not visible to users.
ToArray
A value that can be cast to bytes.
ToBytes
A value that can be cast to bytes.
ToDict
A value that can be cast to dictionary.
ToFloat
A value that can be cast to a float.
ToInt
A value that can be cast to an integer.
Type
Describes a kind of value.
Version
A version with an arbitrary number of components.

Enums§

ArgumentKey
A key that can be used to get an argument: either the index of a positional argument, or the name of a named argument.
Capturer
What the variable was captured by.
CastInfo
Describes a possible value for a cast.
ClosureNode
Distinguishes between variants of closures.
Datetime
Represents a date, a time, or a combination of both.
Endianness
Represents the byte order used for converting integers and floats to bytes and vice versa.
FieldAccessError
An error arising when trying to access a field of content.
Never
An uninhabitable type.
Replacement
A replacement for a matched Str
Selector
A filter for selecting elements within the document.
Smart
A value that can be automatically determined.
StrPattern
A pattern which can be searched for in a string.
StrSide
A side of a string.
Style
A single style property or recipe.
Target
The export target.
ToDecimal
A value that can be cast to a decimal.
ToStr
A value that can be cast to a string.
Transformation
A show rule transformation that can be applied to a match.
UnicodeNormalForm
A Unicode normalization form.
Value
A computational value.
VersionComponents
One or multiple version components.

Constants§

CONTEXT_RULE

Traits§

AlternativeFold
A variant of fold for foldable optional (Option<T>) values where an inner None value isn’t respected (contrary to Option’s usual Fold implementation, with which folding with an inner None always returns None). Instead, when either of the Option objects is None, the other one is necessarily returned by fold_or. Normal folding still occurs when both values are Some, using T’s Fold implementation.
Chainable
Things that can be attached to a style chain.
Construct
An element’s constructor function.
Container
A container for an argument.
ExternalField
A field that is not actually there. It’s only visible in the docs.
Fold
A property that is folded to determine its final value.
FromValue
Try to cast a Typst Value into a Rust type.
IntoArgs
Things that can be used as arguments.
IntoResult
Cast a Rust type or result into a SourceResult<Value>.
IntoValue
Cast a Rust type into a Typst Value.
NativeElement
A Typst element that is defined by a native Rust type.
NativeFunc
A Typst function that is defined by a native Rust type that shadows a native Rust function.
NativeScope
Defines the associated scope of a Rust type.
NativeType
A Typst type that is defined by a native Rust type.
PlainText
Tries to extract the plain-text representation of the element.
RefableProperty
A settable property that can be accessed by reference (because it is not folded).
Reflect
Determine details of a type.
Repr
A trait that defines the repr of a Typst value.
RequiredField
A field that is present on every instance of the element.
Resolve
A property that is resolved with other properties from the style chain.
Set
An element’s set rule.
SettableField
A field that has a default value and can be configured via a set rule, but can also present on elements and be present in the constructor.
SettableProperty
A field that has a default value and can be configured via a set rule, but is never present on elements.
ShowSet
Defines built-in show set rules for an element.
Synthesize
Synthesize fields on an element. This happens before execution of any show rule.
SynthesizedField
A field that is initially unset, but may be set through a Synthesize implementation.
Unlabellable
Indicates that an element cannot be labelled.

Functions§

assert
Ensures that a condition is fulfilled.
convert_float_to_int
eval
Evaluates a string as Typst code.
fields_on
List the available fields for a type.
panic
Fails with an error.
plugin
Loads a WebAssembly module.
target
Returns the current export target.

Type Aliases§

FoldFn
A folding function.
ShowFn
The signature of a native show rule.

Attribute Macros§

elem
Makes a native Rust type usable as a Typst element.
func
Makes a native Rust function usable as a Typst function.
scope
Provides an associated scope to a native function, type, or element.
ty
Makes a native Rust type usable as a Typst type.

Derive Macros§

Cast
Implements Reflect, FromValue, and IntoValue for an enum.