Skip to main content

Crate svg2excal_core

Crate svg2excal_core 

Source
Expand description

Deterministic, security-bounded SVG to Excalidraw conversion.

The crate parses SVG or SVGZ bytes without external I/O, resolves SVG paint semantics through usvg, and emits a typed Excalidraw v2 document. Use convert for the deny-by-default path or convert_with_resources when a caller intentionally provides bounded relative resources.

§Example

use svg2excal_core::{convert, ConversionOptions};

let svg = br##"<svg xmlns="http://www.w3.org/2000/svg" width="20" height="10">
  <rect width="20" height="10" fill="#4dabf7"/>
</svg>"##;
let result = convert(svg, &ConversionOptions::default())?;
let json = result.document.to_pretty_json()?;
assert!(json.contains("\"type\": \"rectangle\""));

Structs§

BinaryFile
Embedded Excalidraw binary file.
CancellationFlag
Cooperative cancellation signal for synchronous conversions.
ConversionDiagnostic
One bounded, deterministic conversion diagnostic.
ConversionLimits
Hard security and output limits applied to every conversion stage.
ConversionOptions
Complete conversion policy.
ConversionReport
Deterministic counts and decisions returned with a successful document.
ConversionResult
Complete successful conversion output.
ExcalidrawAppState
Minimal stable Excalidraw application state.
ExcalidrawDocument
Typed Excalidraw v2 document.
FileId
Content-addressed Excalidraw binary-file identifier.
FontOptions
Deterministic font-policy settings.
GeometryOptions
Geometry approximation settings.
GroupId
Deterministic Excalidraw group identifier.
ProvidedResource
Bytes and declared MIME returned by a provider.
RasterOptions
Raster fallback settings.
RelativeFilePolicy
Policy for caller-provided relative files.
ResourceContext
Couples an allow policy and provider so callbacks cannot widen authority.
ResourceRequest
Validated request passed to a resource provider.

Enums§

ConversionError
Fatal conversion error. No variant contains unbounded source text.
ConversionProfile
Policy used when the source cannot be represented exactly by native target elements.
DiagnosticCode
Stable diagnostic code.
DiagnosticSeverity
Diagnostic severity ordered from informational through painted omission.
ExcalidrawElement
Complete supported Excalidraw element union.
ImageMimeType
Supported embedded output MIME type.
InputRejection
Input-format rejection categories.
LimitResource
Resource whose hard bound was exceeded.
ProvenanceMode
Controls compact source provenance attached to generated elements.
ProvidedResourcePolicy
Core-enforced resource policy. V1 intentionally has no network variant.
ResourceError
Provider failure. Messages are fixed and contain no source path or bytes.

Traits§

ResourceProvider
Synchronous object-safe bounded resource provider.

Functions§

convert
Converts SVG/SVGZ bytes without external I/O.
convert_with_resources
Converts SVG/SVGZ bytes using an explicit bounded resource provider.