Config

Struct Config 

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

The configuration for collecting assets

Implementations§

Source§

impl Config

Source

pub fn with_assets_serve_location( &self, assets_serve_location: impl Into<String>, ) -> Config

The location where assets will be served from. On web applications, this should be the URL path to the directory where assets are served from.

Examples found in repository?
examples/cli.rs (line 14)
4fn main() {
5    use std::process::Command;
6
7    // This is the location where the assets will be copied to in the filesystem
8    let assets_file_location = "./assets";
9    // This is the location where the assets will be served from
10    let assets_serve_location = "/assets";
11
12    // First set any settings you need for the build
13    Config::default()
14        .with_assets_serve_location(assets_serve_location)
15        .save();
16
17    // Next, tell manganis that you support assets
18    let _guard = ManganisSupportGuard::default();
19
20    // Then build your application
21    Command::new("cargo")
22        .args(["build"])
23        .spawn()
24        .unwrap()
25        .wait()
26        .unwrap();
27
28    // Then collect the assets
29    let manifest = AssetManifest::load(Some("test-package"));
30
31    // Remove the old assets
32    let _ = std::fs::remove_dir_all(assets_file_location);
33
34    // And copy the static assets to the public directory
35    manifest
36        .copy_static_assets_to(assets_file_location)
37        .unwrap();
38
39    // Then collect the tailwind CSS
40    let css = manifest.collect_tailwind_css(true, &mut Vec::new());
41
42    // And write the CSS to the public directory
43    std::fs::write(format!("{}/tailwind.css", assets_file_location), css).unwrap();
44}
Source

pub fn assets_serve_location(&self) -> &str

The location where assets will be served from. On web applications, this should be the URL path to the directory where assets are served from.

Source

pub fn current() -> Config

Returns the current config

Source

pub fn save(&self)

Saves the config globally. This must be run before compiling the application you are collecting assets from.

The assets macro will read the config from the global config file and set the assets serve location to the value in the config.

Examples found in repository?
examples/cli.rs (line 15)
4fn main() {
5    use std::process::Command;
6
7    // This is the location where the assets will be copied to in the filesystem
8    let assets_file_location = "./assets";
9    // This is the location where the assets will be served from
10    let assets_serve_location = "/assets";
11
12    // First set any settings you need for the build
13    Config::default()
14        .with_assets_serve_location(assets_serve_location)
15        .save();
16
17    // Next, tell manganis that you support assets
18    let _guard = ManganisSupportGuard::default();
19
20    // Then build your application
21    Command::new("cargo")
22        .args(["build"])
23        .spawn()
24        .unwrap()
25        .wait()
26        .unwrap();
27
28    // Then collect the assets
29    let manifest = AssetManifest::load(Some("test-package"));
30
31    // Remove the old assets
32    let _ = std::fs::remove_dir_all(assets_file_location);
33
34    // And copy the static assets to the public directory
35    manifest
36        .copy_static_assets_to(assets_file_location)
37        .unwrap();
38
39    // Then collect the tailwind CSS
40    let css = manifest.collect_tailwind_css(true, &mut Vec::new());
41
42    // And write the CSS to the public directory
43    std::fs::write(format!("{}/tailwind.css", assets_file_location), css).unwrap();
44}

Trait Implementations§

Source§

impl Debug for Config

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Config

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Config, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Config

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Config

§

impl RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl UnwindSafe for Config

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

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
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.
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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,