MCPcopy Create free account
hub / github.com/bootc-dev/bootc / try_from

Method try_from

crates/kernel_cmdline/src/utf8.rs:366–378  ·  view source on GitHub ↗
(bytes: bytes::Parameter<'a>)

Source from the content-addressed store, hash-verified

364 type Error = anyhow::Error;
365
366 fn try_from(bytes: bytes::Parameter<'a>) -> Result<Self, Self::Error> {
367 if str::from_utf8(bytes.key().deref()).is_err() {
368 anyhow::bail!("Parameter key is not valid UTF-8");
369 }
370
371 if let Some(value) = bytes.value() {
372 if str::from_utf8(value).is_err() {
373 anyhow::bail!("Parameter value is not valid UTF-8");
374 }
375 }
376
377 Ok(Self(bytes))
378 }
379}
380
381impl<'a> std::fmt::Display for Parameter<'a> {

Callers

nothing calls this directly

Calls 3

derefMethod · 0.45
keyMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected