pub struct Previews { /* private fields */ }Expand description
Cached, isolated conversions (one per server, part of AppState).
Implementations§
Source§impl Previews
impl Previews
pub fn new(vault: &Vault, limits: PreviewLimits) -> Previews
Sourcepub async fn render<T, F>(&self, key: &str, work: F) -> AppResult<T>
pub async fn render<T, F>(&self, key: &str, work: F) -> AppResult<T>
Runs CPU-bound work on a derived cache entry – drawing a thumbnail,
composing an assembly preview – off the async runtime: at most
MAX_RENDERS at a time and one at a time per key (the path of
the entry). work must look in the cache before it does anything, so
requests that waited for the same key answer from what the first
one stored instead of doing it again. A request that only reads the
cache does not come here and never waits for a slot.
The slot and the turn stay taken until work returns, also when the
request that started it is gone: a blocking thread cannot be stopped,
and its work is still running.
Sourcepub fn queue(&self) -> (usize, usize)
pub fn queue(&self) -> (usize, usize)
The preview queue: conversions running now and conversions waiting
for a free slot (at most MAX_PARALLEL run at a time).
Sourcepub fn assembly_path(&self, sha256: &str, key: &str) -> AppResult<PathBuf>
pub fn assembly_path(&self, sha256: &str, key: &str) -> AppResult<PathBuf>
Where the composed preview of an assembly is cached: next to the
blob’s own preview, named by the components it was built from
(key, hex), so a changed component gives a new file.
Sourcepub async fn mass_geometry(
&self,
vault: &Vault,
sha256: &str,
format: PreviewFormat,
) -> AppResult<Geometry>
pub async fn mass_geometry( &self, vault: &Vault, sha256: &str, format: PreviewFormat, ) -> AppResult<Geometry>
The mass properties of a blob per unit density in model units (see
massprops): from the cache, or computed from the cached preview
mesh in the isolated preview process (converting the file first if
needed). Failures are cached like failed previews.
Sourcepub async fn has_mesh(&self, sha256: &str) -> bool
pub async fn has_mesh(&self, sha256: &str) -> bool
Whether the preview mesh of a blob is already cached.
Sourcepub async fn is_converted(&self, sha256: &str) -> bool
pub async fn is_converted(&self, sha256: &str) -> bool
Whether the conversion of a blob is behind us: its preview mesh or the reason why there is none is cached.
Sourcepub async fn signature(
&self,
vault: &Vault,
sha256: &str,
format: PreviewFormat,
) -> AppResult<Signature>
pub async fn signature( &self, vault: &Vault, sha256: &str, format: PreviewFormat, ) -> AppResult<Signature>
The shape signature of a blob (see shape): from the cache, written
by the conversion, or computed from the cached preview mesh in the
isolated preview process. Failures are cached like failed previews.
Auto Trait Implementations§
impl !Freeze for Previews
impl !RefUnwindSafe for Previews
impl !UnwindSafe for Previews
impl Send for Previews
impl Sync for Previews
impl Unpin for Previews
impl UnsafeUnpin for Previews
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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 moreimpl<T> Parallelizable for T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
§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.