MCPcopy Index your code
hub / github.com/emwalker/digraph / parts

Method parts

backend/src/types.rs:289–308  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

287 }
288
289 pub fn parts(&self) -> Result<(&str, &str, &str)> {
290 lazy_static! {
291 static ref RE: Regex = Regex::new(r"^([\w_-]{2})([\w_-]{2})([\w_-]+)$").unwrap();
292 }
293
294 let cap = RE
295 .captures(self.0.as_str())
296 .ok_or_else(|| Error::Path(format!("bad id: {self}")))?;
297
298 if cap.len() != 4 {
299 return Err(Error::Path(format!("bad id: {self}")));
300 }
301
302 match (cap.get(1), cap.get(2), cap.get(3)) {
303 (Some(part1), Some(part2), Some(part3)) => {
304 Ok((part1.as_str(), part2.as_str(), part3.as_str()))
305 }
306 _ => Err(Error::Path(format!("bad id: {self}"))),
307 }
308 }
309}
310
311// Lookup key for a topic or link from the standpoint of a specific repo.

Callers

nothing calls this directly

Calls 3

as_strMethod · 0.80
lenMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected