Struct webmanifest::Manifest

source ·
pub struct Manifest<'s, 'i, 'r> { /* private fields */ }
Expand description

Create a new manifest builder.

Implementations§

Create a new instance.

Example
let name = "My Cool Application";
let builder = Manifest::builder(name);

Finalize the builder and create the manifest.

Example
let name = "My Cool Application";
let manifest = Manifest::builder(name).build()?;

Finalize the builder and create a pretty representation of the manifest.

Example
let name = "My Cool Application";
let manifest = Manifest::builder(name).pretty()?;

Set the short_name value.

Panics

This will panic if the short name exceeds 12 characters.

Example
let name = "My Cool Application";
let manifest = Manifest::builder(name)
  .short_name("Cool App")
  .build()?;

Set the start_url value.

Example
let name = "My Cool Application";
let manifest = Manifest::builder(name)
  .start_url(".")
  .build()?;

Set the display value.

Example
let name = "My Cool Application";
let manifest = Manifest::builder(name)
  .display_mode(DisplayMode::Standalone)
  .build()?;

Set the background_color value.

Example
let name = "My Cool Application";
let manifest = Manifest::builder(name)
  .bg_color("#000")
  .build()?;

Set the theme_color value.

Example
let name = "My Cool Application";
let manifest = Manifest::builder(name)
  .theme_color("#000")
  .build()?;

Set the description value.

Example
let name = "My Cool Application";
let desc = "It does many things.";
let manifest = Manifest::builder(name)
  .description(desc)
  .build()?;

Set the lang value.

Specifies the primary language for the values in the name and short_name members. This value is a string containing a single language tag.

Example
let name = "My Cool Application";
let lang = "en-US";
let manifest = Manifest::builder(name)
  .lang(lang)
  .build()?;

Set the orientation value.

Specifies a boolean value that hints for the user agent to indicate to the user that the specified native applications are recommended over the website. This should only be used if the related native apps really do offer something that the website can’t.

Example
let name = "My Cool Application";
let manifest = Manifest::builder(name)
  .orientation(Orientation::Portrait)
  .build()?;

Set the dir value.

Specifies the primary text direction for the name, short_name, and description members. Together with the lang member, it helps the correct display of right-to-left languages.

Example
let name = "My Cool Application";
let lang = "en-US";
let manifest = Manifest::builder(name)
  .direction(Direction::Ltr)
  .build()?;

Set the prefer_related_applications value.

Specifies a boolean value that hints for the user agent to indicate to the user that the specified native applications are recommended over the website. This should only be used if the related native apps really do offer something that the website can’t.

Note

If omitted, the value defaults to false.

Example
let name = "My Cool Application";
let manifest = Manifest::builder(name)
  .prefer_related_applications(true)
  .build()?;

Set the scope value.

Defines the navigation scope of this website’s context. This restricts what web pages can be viewed while the manifest is applied. If the user navigates outside the scope, it returns to a normal web page inside a browser tab/window.

If the scope is a relative URL, the base URL will be the URL of the manifest.

Example
let name = "My Cool Application";
let manifest = Manifest::builder(name)
  .scope("/myapp/")
  .build()?;

Add an Icon to the icons vector.

Example
let name = "My Cool Application";
let src = "images/touch/homescreen48.png";
let manifest = Manifest::builder(name)
  .icon(&Icon::new(&src, "48x48"))
  .build()?;

Add an Related application to the related_applications vector.

Example
let name = "My Cool Application";
let url = "https://play.google.com/store/apps/details?id=cheeaun.hackerweb";
let manifest = Manifest::builder(name)
  .related(&Related::new("play", url))
  .build()?;

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.