pub struct ResourceContainer<'a> { /* private fields */ }Implementations§
Source§impl<'a> ResourceContainer<'a>
impl<'a> ResourceContainer<'a>
Sourcepub fn new(output_path: &'a Path) -> Self
pub fn new(output_path: &'a Path) -> Self
Creates a new empty container.
Examples found in repository?
examples/container.rs (line 6)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
fn main() -> std::io::Result<()> {
let mut container = ResourceContainer::new(Path::new("embed"));
// Add resources from different sources
container.add_resource("local_file", Resource::File("Cargo.toml".to_string()), true);
container.add_resource(
"remote_file",
Resource::Url("https://zenosmosis.com".to_string()),
true,
);
container.add_resource(
"arbitrary_data",
Resource::Data(bytes::Bytes::from("Hello, world!")),
true,
);
// Embed all resources into the "embed" directory with compression
container.embed_all()?;
Ok(())
}Sourcepub fn add_resource(&mut self, name: &str, resource: Resource, compress: bool)
pub fn add_resource(&mut self, name: &str, resource: Resource, compress: bool)
Adds a resource to the container.
Examples found in repository?
examples/container.rs (line 9)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
fn main() -> std::io::Result<()> {
let mut container = ResourceContainer::new(Path::new("embed"));
// Add resources from different sources
container.add_resource("local_file", Resource::File("Cargo.toml".to_string()), true);
container.add_resource(
"remote_file",
Resource::Url("https://zenosmosis.com".to_string()),
true,
);
container.add_resource(
"arbitrary_data",
Resource::Data(bytes::Bytes::from("Hello, world!")),
true,
);
// Embed all resources into the "embed" directory with compression
container.embed_all()?;
Ok(())
}Sourcepub fn embed_all(&self) -> Result<()>
pub fn embed_all(&self) -> Result<()>
Processes all resources and writes them to the embed directory.
Examples found in repository?
examples/container.rs (line 22)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
fn main() -> std::io::Result<()> {
let mut container = ResourceContainer::new(Path::new("embed"));
// Add resources from different sources
container.add_resource("local_file", Resource::File("Cargo.toml".to_string()), true);
container.add_resource(
"remote_file",
Resource::Url("https://zenosmosis.com".to_string()),
true,
);
container.add_resource(
"arbitrary_data",
Resource::Data(bytes::Bytes::from("Hello, world!")),
true,
);
// Embed all resources into the "embed" directory with compression
container.embed_all()?;
Ok(())
}Auto Trait Implementations§
impl<'a> Freeze for ResourceContainer<'a>
impl<'a> RefUnwindSafe for ResourceContainer<'a>
impl<'a> Send for ResourceContainer<'a>
impl<'a> Sync for ResourceContainer<'a>
impl<'a> Unpin for ResourceContainer<'a>
impl<'a> UnwindSafe for ResourceContainer<'a>
Blanket Implementations§
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