pub struct GenerateWebfontsResult { /* private fields */ }Expand description
Result of a successful generateWebfonts call. Exposes the generated
font bytes (or null for formats that were not requested) and methods to
render the CSS and HTML preview.
Implementations§
Source§impl GenerateWebfontsResult
impl GenerateWebfontsResult
Sourcepub fn add(
&mut self,
path: String,
name: Option<String>,
variant: Option<&str>,
) -> Result<()>
pub fn add( &mut self, path: String, name: Option<String>, variant: Option<&str>, ) -> Result<()>
Append a new file and regenerate. Families require an existing target variant.
name overrides the file stem. Requires incremental generation and inherits
Self::regenerate’s validation, callback restrictions and write/failure semantics.
Sourcepub fn update(&mut self, path: String, name: Option<String>) -> Result<()>
pub fn update(&mut self, path: String, name: Option<String>) -> Result<()>
Re-read an existing file in every consuming design, preserving its position.
An absent name preserves the glyph name. Inherits Self::regenerate’s semantics.
Sourcepub fn remove(&mut self, path: String) -> Result<()>
pub fn remove(&mut self, path: String) -> Result<()>
Remove an existing file from every design without deleting it from disk.
Rejects empty designs. Inherits Self::regenerate’s semantics.
Sourcepub async fn add_async(
self,
path: String,
name: Option<String>,
variant: Option<String>,
) -> Result<Self, RegenerateError>
pub async fn add_async( self, path: String, name: Option<String>, variant: Option<String>, ) -> Result<Self, RegenerateError>
Consuming async equivalent of Self::add, with Self::regenerate_async’s recovery semantics.
Sourcepub async fn update_async(
self,
path: String,
name: Option<String>,
) -> Result<Self, RegenerateError>
pub async fn update_async( self, path: String, name: Option<String>, ) -> Result<Self, RegenerateError>
Consuming async equivalent of Self::update, with Self::regenerate_async’s recovery semantics.
Sourcepub async fn remove_async(self, path: String) -> Result<Self, RegenerateError>
pub async fn remove_async(self, path: String) -> Result<Self, RegenerateError>
Consuming async equivalent of Self::remove, with Self::regenerate_async’s recovery semantics.
Sourcepub async fn add_snapshot_async(
&self,
path: String,
name: Option<String>,
variant: Option<String>,
) -> Result<Self>
pub async fn add_snapshot_async( &self, path: String, name: Option<String>, variant: Option<String>, ) -> Result<Self>
Snapshot-preserving async addition for adapters; inherits Self::regenerate_snapshot_async’s lineage and cancellation rules.
Sourcepub async fn update_snapshot_async(
&self,
path: String,
name: Option<String>,
) -> Result<Self>
pub async fn update_snapshot_async( &self, path: String, name: Option<String>, ) -> Result<Self>
Snapshot-preserving async update for adapters; inherits Self::regenerate_snapshot_async’s lineage and cancellation rules.
Sourcepub async fn remove_snapshot_async(&self, path: String) -> Result<Self>
pub async fn remove_snapshot_async(&self, path: String) -> Result<Self>
Snapshot-preserving async removal for adapters; inherits Self::regenerate_snapshot_async’s lineage and cancellation rules.
Source§impl GenerateWebfontsResult
impl GenerateWebfontsResult
Sourcepub fn regenerate(
&mut self,
files: &RegenerationFiles,
changes: &[(String, GlyphChange)],
) -> Result<()>
pub fn regenerate( &mut self, files: &RegenerationFiles, changes: &[(String, GlyphChange)], ) -> Result<()>
Rebuild after a batch of file changes, reusing cached glyph geometry for files whose
contents are unchanged. Requires the result to have been generated with incremental
enabled. files selects the matching ordinary or variant input mode. Each contained list
is the complete file set after the changes, in the order a fresh
build would use (e.g. the glob result); the rebuilt glyphs are ordered to match it, so
auto-assigned codepoints and glyph order — and therefore the output bytes — are identical
to a fresh generate of that set, including for additions that sort before existing
glyphs. changes describes what to do per affected file: added/changed files are read from
disk and re-parsed; any file absent from its list is dropped (an explicit Removed
is optional but harmless). Every requested format is rebuilt in memory, and — matching
generate — when the result was built with write_files enabled the refreshed fonts are
written to disk too, while CSS/HTML companion files are skipped if their rendered bytes are
unchanged from the previous write. Rendered CSS/HTML is reused when the glyph names and
codepoints the templates read are unchanged (a content edit), and re-rendered otherwise.
For families, supply every configured variant exactly once. Each design’s file order is
independent. Hints describe family-wide paths: Added is new to the family, Changed
applies to every final consumer, and Removed must be absent from every final list.
Membership-only changes need no hint; newly assigned paths are loaded automatically.
Invalid batches and font-build failures preserve the previous result. Variant writes
occur after the new state commits, so write errors leave retryable new in-memory output.
use webfont_generator::{
generate_sync, FontType, GenerateWebfontsOptions, GlyphChange,
};
let files = vec![
"icons/add.svg".to_owned(),
"icons/remove.svg".to_owned(),
];
let mut result = generate_sync(
GenerateWebfontsOptions {
dest: "dist".to_owned(),
files: files.clone(),
incremental: Some(true),
types: Some(vec![FontType::Woff2]),
write_files: Some(false),
..Default::default()
},
None,
)?;
result.regenerate(
&webfont_generator::RegenerationFiles::Single(files),
&[(
"icons/add.svg".to_owned(),
GlyphChange::Changed { name: None },
)],
)?;Sourcepub async fn regenerate_async(
self,
files: RegenerationFiles,
changes: Vec<(String, GlyphChange)>,
) -> Result<Self, RegenerateError>
pub async fn regenerate_async( self, files: RegenerationFiles, changes: Vec<(String, GlyphChange)>, ) -> Result<Self, RegenerateError>
Asynchronously rebuild on Tokio’s blocking pool and return the next result generation.
This consumes self, so Rust prevents reuse of a stale result after success. On ordinary
failure, RegenerateError::into_result returns the input result for retry. This future is
not cancellation-safe: dropping it lets already-started blocking work finish and drops the
consumed result; filesystem writes may continue.
use webfont_generator::{generate_sync, GenerateWebfontsOptions, GlyphChange};
let files = vec!["icons/add.svg".to_owned()];
let result = generate_sync(GenerateWebfontsOptions {
files: files.clone(),
dest: "dist".to_owned(),
incremental: Some(true),
..Default::default()
}, None)?;
let result = result.regenerate_async(
webfont_generator::RegenerationFiles::Single(files.clone()),
vec![(files[0].clone(), GlyphChange::Changed { name: None })],
).await?;Sourcepub fn regenerate_all(&mut self, files: &RegenerationFiles) -> Result<()>
pub fn regenerate_all(&mut self, files: &RegenerationFiles) -> Result<()>
Rebuild after re-diffing the complete ordered file set against the retained incremental cache. This is useful when the caller has a fresh file list but not a reliable watcher change batch: every current path is re-read and hashed, missing prior paths are treated as removed, new paths as added, and paths whose content hash changed as changed. Existing glyph names are preserved; added paths derive their glyph name from the file stem.
use webfont_generator::{generate_sync, GenerateWebfontsOptions};
let files = vec!["icons/add.svg".to_owned()];
let mut result = generate_sync(GenerateWebfontsOptions {
files: files.clone(),
dest: "dist".to_owned(),
incremental: Some(true),
..Default::default()
}, None)?;
result.regenerate_all(&webfont_generator::RegenerationFiles::Single(files))?;Sourcepub async fn regenerate_all_async(
self,
files: RegenerationFiles,
) -> Result<Self, RegenerateError>
pub async fn regenerate_all_async( self, files: RegenerationFiles, ) -> Result<Self, RegenerateError>
Asynchronously re-diff and rebuild on Tokio’s blocking pool, consuming the old result and returning the next result generation. This future is not cancellation-safe: dropping it lets already-started blocking work finish and drops the consumed result.
use webfont_generator::{generate_sync, GenerateWebfontsOptions};
let files = vec!["icons/add.svg".to_owned()];
let result = generate_sync(GenerateWebfontsOptions {
files: files.clone(),
dest: "dist".to_owned(),
incremental: Some(true),
..Default::default()
}, None)?;
let result = result.regenerate_all_async(webfont_generator::RegenerationFiles::Single(files)).await?;Source§impl GenerateWebfontsResult
impl GenerateWebfontsResult
Sourcepub fn generate_ts(&self) -> Result<Arc<String>>
pub fn generate_ts(&self) -> Result<Arc<String>>
Render a fixed TypeScript source module with icons, IconName,
iconBaseSelector, and iconClassPrefix. Repeated calls share the output.
Uses effective CSS context settings, independent of CSS/HTML templates or output flags.
Source§impl GenerateWebfontsResult
impl GenerateWebfontsResult
Sourcepub async fn regenerate_snapshot_async(
&self,
files: RegenerationFiles,
changes: Option<Vec<(String, GlyphChange)>>,
) -> Result<Self>
pub async fn regenerate_snapshot_async( &self, files: RegenerationFiles, changes: Option<Vec<(String, GlyphChange)>>, ) -> Result<Self>
Rebuild on Tokio’s blocking pool, preserving this result as a readable snapshot.
Returns a replacement result on success. This result remains readable, but can no longer regenerate after it has been replaced. Concurrent regeneration attempts on the same result are rejected. On failure, its regeneration state is restored for retry, including reconciliation of any partially completed variant output writes.
Pass Some(changes) to supply explicit changes, or None to infer them from the
complete input membership. Requires generation with incremental: true.
Unlike Self::regenerate_async, this method borrows rather than consumes the
receiver. Prefer the consuming API when Rust ownership can enforce replacement.
This future is not cancellation-safe: dropping it does not stop blocking work or
filesystem writes. If that work succeeds, this receiver remains replaced even
though the new result can no longer be retrieved from the dropped future.
Source§impl GenerateWebfontsResult
impl GenerateWebfontsResult
Sourcepub fn svg_string(&self) -> Option<&str>
pub fn svg_string(&self) -> Option<&str>
Returns the SVG font string, if generated.
Sourcepub fn woff_bytes(&self) -> Option<&[u8]>
pub fn woff_bytes(&self) -> Option<&[u8]>
Returns the WOFF font bytes, if generated.
Sourcepub fn woff2_bytes(&self) -> Option<&[u8]>
pub fn woff2_bytes(&self) -> Option<&[u8]>
Returns the WOFF2 font bytes, if generated.
Auto Trait Implementations§
impl !Freeze for GenerateWebfontsResult
impl !RefUnwindSafe for GenerateWebfontsResult
impl !UnwindSafe for GenerateWebfontsResult
impl Send for GenerateWebfontsResult
impl Sync for GenerateWebfontsResult
impl Unpin for GenerateWebfontsResult
impl UnsafeUnpin for GenerateWebfontsResult
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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T, using the provided data to resolve any offsets.