Skip to main content

Artifact

Struct Artifact 

Source
pub struct Artifact { /* private fields */ }
Expand description

A build output of fetchlet/build: fetchlet.json, the server module and the client assets.

Artifact::open reads a directory; the manifest names the files relative to it, and paths that leave it are refused, so a manifest cannot point the server at other files. include_artifact! embeds the manifest, the server module and the asset archive in the binary instead. An asset archive is read and checked when the artifact is created.

Implementations§

Source§

impl Artifact

Source

pub fn open(directory: impl Into<PathBuf>) -> Result<Self, ArtifactError>

Read fetchlet.json in directory.

Source

pub fn embedded( manifest: &[u8], server: impl Into<Cow<'static, str>>, assets: Option<Bytes>, ) -> Result<Self, ArtifactError>

An artifact whose files are in memory, usually through include_artifact!. assets is required when the manifest names an asset archive. Embedded artifacts have no client directory.

Source

pub fn directory(&self) -> Option<&Path>

The artifact directory, for an artifact read with Artifact::open.

Source

pub fn handler(&self) -> Option<&str>

The export of the server module that handles Fetch requests, for AppBuilder::fetch_handler. None for an artifact of functions only, whose App refuses fetch and serves call.

Source

pub fn functions(&self) -> Option<&[String]>

The functions the server module exports for App::call, when the manifest records them.

Source

pub fn backend(&self) -> Option<&str>

The engine the server module was built for, such as quickjs.

Source

pub fn requirements(&self) -> Requirements

What the server module needs from the host that runs it, for fetchlet::Module::requires: the engine APIs the build left to the engine and their locales, the engine’s async context, and the Web APIs and protocol of fetchlet-web. Building an App with them refuses a host that lacks one before the module runs.

ⓘ
let module = Module::new(artifact.server_source()?).requires(artifact.requirements());

For a manifest without needs, they come from nativeRequirements, intl.locales and asyncContext.

Source

pub fn server_path(&self) -> Option<PathBuf>

The server module’s file, for an artifact read from a directory.

Source

pub fn server_source(&self) -> Result<String, ArtifactError>

The server module’s source, for fetchlet::Module::new.

Source

pub fn client_directory(&self) -> Option<PathBuf>

The directory of public client assets, when the framework has any and the artifact was read from a directory.

Source

pub fn asset_archive(&self) -> Option<&Arc<AssetArchive>>

The client assets packed by archiveArtifactAssets, when the manifest names an archive.

Source

pub fn default_worker_options() -> WorkerOptions

Default WorkerOptions suitable for SSR frameworks: a queue of 8 commands, one instance, and a 64 MiB native worker stack.

Source

pub fn default_limits() -> Limits

Default Limits for serving an artifact: a 10 s busy_timeout and a 60 s startup_timeout.

Source

pub fn default_backend(&self) -> Result<Backend>

The engine this artifact targets (Backend::for_target), with safe default QuickJS (4 MiB) and Boa (131,072 value stack slots, 10,000 recursion calls) stack limits for use with Self::default_worker_options.

Source

pub fn app_builder(&self) -> Result<AppBuilder, ArtifactError>

An AppBuilder preconfigured for this artifact: its target backend with safe stack defaults, Module with artifact.requirements(), fetch_handler(artifact.handler()), Self::default_limits (plus a 64 MiB heap limit on engines that enforce it), and the current multi-thread Tokio runtime as host_runtime when available.

Pair with Self::default_worker_options when integrating into a custom Tower, hyper, axum, or actix-web server.

Source

pub fn app_builder_with( &self, backend: Backend, ) -> Result<AppBuilder, ArtifactError>

Like Self::app_builder, using an explicit Backend while still wiring up server_source, requirements, handler, safe default limits, and host_runtime.

Trait Implementations§

Source§

impl Clone for Artifact

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Artifact

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ParallelSend for T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more