Builder

Struct Builder 

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

A Bundle builder.

Implementations§

Source§

impl Builder

Source

pub fn version(self, version: Version) -> Self

Sets the version.

Source

pub fn primary_url(self, primary_url: Uri) -> Self

Sets the primary url.

Source

pub fn manifest(self, manifest: Uri) -> Self

Sets the manifest url.

Source

pub fn exchange(self, exchange: Exchange) -> Self

Adds the exchange.

Source

pub fn build(self) -> Result<Bundle>

Builds the bundle.

Source§

impl Builder

Source

pub async fn exchanges_from_dir(self, dir: impl AsRef<Path>) -> Result<Self>

Append exchanges from files rooted at the given directory.

One exchange is created for each file, however, two exchanges are created for index.html file, as follows:

  1. The pareent directory serves the contents of index.html file.
  2. The URL for index.html file is a redirect to the parent directory (301 MOVED PERMANENTLY).
§Examples
use webbundle::{Bundle, Version};
let bundle = Bundle::builder()
    .version(Version::VersionB2)
    .exchanges_from_dir("build").await?
    .build()?;
Source

pub fn exchanges_from_dir_sync(self, dir: impl AsRef<Path>) -> Result<Self>

Sync version of exchanges_from_dir.

Trait Implementations§

Source§

impl Default for Builder

Source§

fn default() -> Builder

Returns the “default value” for a type. 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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.