pub struct Config { /* private fields */ }Expand description
The configuration for collecting assets
Implementations§
Source§impl Config
impl Config
Sourcepub fn with_assets_serve_location(
&self,
assets_serve_location: impl Into<String>,
) -> Config
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}Sourcepub fn assets_serve_location(&self) -> &str
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.
Sourcepub fn save(&self)
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<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Config, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
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
impl Serialize for Config
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Mutably borrows from an owned value. Read more
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
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 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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
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().