pub struct TemplateDownloadService { /* private fields */ }Expand description
Service for downloading and caching project templates from GitHub
Implementations§
Source§impl TemplateDownloadService
impl TemplateDownloadService
Sourcepub fn with_cache_dir(cache_dir: PathBuf) -> Self
pub fn with_cache_dir(cache_dir: PathBuf) -> Self
Create a TemplateService with a custom cache directory (for testing)
Sourcepub async fn get_latest_version(&self) -> Result<String>
pub async fn get_latest_version(&self) -> Result<String>
Get the latest template version from GitHub releases
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 ensure_templates(&self, version: &str) -> Result<PathBuf>
pub async fn ensure_templates(&self, version: &str) -> Result<PathBuf>
Ensure templates are available for a specific version
Downloads and caches templates if not already present. Returns the path to the templates directory.
Sourcepub fn read_template(
&self,
version: &str,
relative_path: &str,
) -> Result<String>
pub fn read_template( &self, version: &str, relative_path: &str, ) -> Result<String>
Read a template file from the cached templates
Sourcepub fn read_template_bytes(
&self,
version: &str,
relative_path: &str,
) -> Result<Vec<u8>>
pub fn read_template_bytes( &self, version: &str, relative_path: &str, ) -> Result<Vec<u8>>
Read a binary template file from the cached templates
Sourcepub fn list_template_dir(
&self,
version: &str,
relative_path: &str,
) -> Result<Vec<PathBuf>>
pub fn list_template_dir( &self, version: &str, relative_path: &str, ) -> Result<Vec<PathBuf>>
List all files in a template directory
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TemplateDownloadService
impl RefUnwindSafe for TemplateDownloadService
impl Send for TemplateDownloadService
impl Sync for TemplateDownloadService
impl Unpin 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
Mutably borrows from an owned value. Read more
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 more