Enum deno_core::ModuleCode
source · pub enum ModuleCode {
Static(&'static [u8]),
Owned(Vec<u8>),
Arc(Arc<str>),
}
Expand description
Module code can be sourced from strings or bytes that are either owned or borrowed. This enumeration allows us to perform a minimal amount of cloning and format-shifting of the underlying data.
Note that any ModuleCode
created from a 'static
byte array or string must contain ASCII characters.
Examples of ways to construct a ModuleCode
object:
let code: ModuleCode = "a string".into();
let code: ModuleCode = b"a string".into();
Variants§
Static(&'static [u8])
Created from static data – must be 100% 7-bit ASCII!
Owned(Vec<u8>)
An owned chunk of data.
Arc(Arc<str>)
Scripts loaded from the deno_graph
infrastructure.
Implementations§
source§impl ModuleCode
impl ModuleCode
pub fn as_bytes(&self) -> &[u8] ⓘ
pub fn try_static_ascii(&self) -> Option<&'static [u8]>
sourcepub fn take_as_string(self) -> String
pub fn take_as_string(self) -> String
Takes a ModuleCode
value as an owned String
. May be slow.