wasi-common 0.9.0

WASI implementation in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
use crate::{Error, Result};
use std::str;

/// Creates not-owned WASI path from byte slice.
///
/// NB WASI spec requires bytes to be valid UTF-8. Otherwise,
/// `__WASI_ERRNO_ILSEQ` error is returned.
pub(crate) fn path_from_slice<'a>(s: &'a [u8]) -> Result<&'a str> {
    str::from_utf8(s).map_err(|_| Error::EILSEQ)
}