pub enum Detect {
WasmText,
WasmBinary,
Unknown,
}
Expand description
Result of Detect::from_bytes
to indicate what some input bytes look
like.
Variants§
WasmText
The input bytes look like the WebAssembly text format.
WasmBinary
The input bytes look like the WebAssembly binary format.
Unknown
The input bytes don’t look like WebAssembly at all.
Implementations§
Source§impl Detect
impl Detect
Sourcepub fn from_bytes(bytes: impl AsRef<[u8]>) -> Detect
pub fn from_bytes(bytes: impl AsRef<[u8]>) -> Detect
Detect quickly if supplied bytes represent a Wasm module, whether binary encoded or in WAT-encoded.
This briefly lexes past whitespace and comments as a *.wat
file to see if
we can find a left-paren. If that fails then it’s probably *.wit
instead.
Examples
use wat::Detect;
assert_eq!(Detect::from_bytes(r#"
(module
(type (;0;) (func))
(func (;0;) (type 0)
nop
)
)
"#), Detect::WasmText);
Trait Implementations§
impl Copy for Detect
impl Eq for Detect
impl StructuralPartialEq for Detect
Auto Trait Implementations§
impl Freeze for Detect
impl RefUnwindSafe for Detect
impl Send for Detect
impl Sync for Detect
impl Unpin for Detect
impl UnwindSafe for Detect
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.