Slug-shape check for a candidate trace id. Same rule used by `validate` for `Trace.id`, exposed standalone so callers (e.g. `trace init`) can reject bad ids without constructing a full `Trace`.
(id: &str)
| 107 | /// for `Trace.id`, exposed standalone so callers (e.g. `trace init`) can |
| 108 | /// reject bad ids without constructing a full `Trace`. |
| 109 | pub fn validate_trace_id(id: &str) -> Result<()> { |
| 110 | if !trace_id_re().is_match(id) { |
| 111 | return Err(TraceError::Validation(format!( |
| 112 | "id `{}` must be a slug: start with a letter, then [a-z0-9-], 1–63 chars total", |
| 113 | id |
| 114 | ))); |
| 115 | } |
| 116 | Ok(()) |
| 117 | } |
| 118 | |
| 119 | pub fn validate(r: &Trace) -> Result<()> { |
| 120 | validate_trace_id(&r.id)?; |
no test coverage detected
searching dependent graphs…