pub struct TemplateDownloadService { /* private fields */ }Implementations§
Source§impl TemplateDownloadService
impl TemplateDownloadService
Sourcepub fn new() -> TemplateDownloadService
pub fn new() -> TemplateDownloadService
Create a new TemplateDownloadService with default cache directory
Sourcepub fn with_cache_dir(cache_dir: PathBuf) -> TemplateDownloadService
pub fn with_cache_dir(cache_dir: PathBuf) -> TemplateDownloadService
Create a TemplateDownloadService with a custom cache directory (for testing)
Sourcepub async fn get_latest_version(&self) -> Result<String, Error>
pub async fn get_latest_version(&self) -> Result<String, Error>
Get the latest template version via mecha10-api
Calls GET /api/downloads/templates/version, which resolves the version
Sourcepub fn get_cached_path(&self, version: &str) -> PathBuf
pub fn get_cached_path(&self, version: &str) -> PathBuf
Get the path to cached templates for a specific version
Sourcepub fn is_cached(&self, version: &str) -> bool
pub fn is_cached(&self, version: &str) -> bool
Check if templates for a specific version are cached
Sourcepub async fn resolve_version(&self) -> Result<String, Error>
pub async fn resolve_version(&self) -> Result<String, Error>
Resolve which template version to use.
Prefers a locally --installed dev build (DEV_VERSION) if one is cached. Falls
Sourcepub async fn ensure_templates(&self, version: &str) -> Result<PathBuf, Error>
pub async fn ensure_templates(&self, version: &str) -> Result<PathBuf, Error>
Ensure templates are available for a specific version
Downloads and caches templates if not already present.
Sourcepub fn read_template(
&self,
version: &str,
relative_path: &str,
) -> Result<String, Error>
pub fn read_template( &self, version: &str, relative_path: &str, ) -> Result<String, Error>
Read a template file from the cached templates as UTF-8 text.
Built on Self::read_template_bytes, decoding the bytes variant’s result as text.
Sourcepub fn read_template_bytes(
&self,
version: &str,
relative_path: &str,
) -> Result<Vec<u8>, Error>
pub fn read_template_bytes( &self, version: &str, relative_path: &str, ) -> Result<Vec<u8>, Error>
Read a binary template file from the cached templates
Sourcepub fn list_template_dir(
&self,
version: &str,
relative_path: &str,
) -> Result<Vec<PathBuf>, Error>
pub fn list_template_dir( &self, version: &str, relative_path: &str, ) -> Result<Vec<PathBuf>, Error>
List all files in a template directory
Trait Implementations§
Source§impl Clone for TemplateDownloadService
impl Clone for TemplateDownloadService
Source§fn clone(&self) -> TemplateDownloadService
fn clone(&self) -> TemplateDownloadService
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for TemplateDownloadService
impl Default for TemplateDownloadService
Source§fn default() -> TemplateDownloadService
fn default() -> TemplateDownloadService
Auto Trait Implementations§
impl Freeze for TemplateDownloadService
impl RefUnwindSafe for TemplateDownloadService
impl Send for TemplateDownloadService
impl Sync for TemplateDownloadService
impl Unpin for TemplateDownloadService
impl UnsafeUnpin for TemplateDownloadService
impl UnwindSafe for TemplateDownloadService
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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