MCPcopy Index your code
hub / github.com/cargo-lambda/cargo-lambda / try_from

Method try_from

crates/cargo-lambda-new/src/template.rs:102–127  ·  view source on GitHub ↗
(value: &str)

Source from the content-addressed store, hash-verified

100 type Error = miette::Error;
101
102 fn try_from(value: &str) -> Result<Self, Self::Error> {
103 if is_remote_zip_file(value) {
104 return Ok(Self::RemoteZip(value.into()));
105 }
106
107 if let Some(repo) = match_git_http_url(value) {
108 return Ok(Self::RemoteRepo(repo));
109 }
110
111 if let Some(repo) = match_git_ssh_url(value) {
112 return Ok(Self::RemoteRepo(repo));
113 }
114
115 if !(value.starts_with("https://")) {
116 if let Some(path) = find_local_zip_file(value) {
117 return Ok(Self::LocalZip(path));
118 }
119
120 let path = find_local_directory(value)?;
121 return Ok(Self::LocalDir(path));
122 }
123
124 Err(miette::miette!(
125 "the given template option is not a valid Git URL or local directory: {value}"
126 ))
127 }
128}
129
130pub(crate) enum TemplateRoot {

Callers

nothing calls this directly

Calls 5

is_remote_zip_fileFunction · 0.85
match_git_http_urlFunction · 0.85
match_git_ssh_urlFunction · 0.85
find_local_zip_fileFunction · 0.85
find_local_directoryFunction · 0.85

Tested by

no test coverage detected