shuttle_static_folder/
lib.rs1use std::path::PathBuf;
2
3use async_trait::async_trait;
4use serde::Serialize;
5use shuttle_service::{Error, Factory, ResourceBuilder, Type};
6
7#[derive(Serialize)]
8#[deprecated(
9 since = "0.27.0",
10 note = "Folder names can now be hard coded. More about deployment files: https://docs.shuttle.rs/configuration/files"
11)]
12pub struct StaticFolder<'a> {
13 folder: &'a str,
15}
16
17impl<'a> StaticFolder<'a> {
18 pub fn folder(mut self, folder: &'a str) -> Self {
19 self.folder = folder;
20
21 self
22 }
23}
24
25#[async_trait]
26impl<'a> ResourceBuilder<PathBuf> for StaticFolder<'a> {
27 const TYPE: Type = Type::StaticFolder;
28
29 type Config = &'a str;
30
31 type Output = PathBuf;
32
33 fn new() -> Self {
34 Self { folder: "static" }
35 }
36
37 fn config(&self) -> &&'a str {
38 &self.folder
39 }
40
41 async fn output(self, _factory: &mut dyn Factory) -> Result<Self::Output, Error> {
42 Ok(PathBuf::from(self.folder))
43 }
44
45 async fn build(build_data: &Self::Output) -> Result<PathBuf, Error> {
46 Ok(build_data.clone())
47 }
48}