Type Alias deno_core::ModuleCode
source · pub type ModuleCode = FastString;
Aliased Type§
enum ModuleCode {
Static(&'static str),
StaticAscii(&'static str),
Owned(Box<str, Global>),
Arc(Arc<str, Global>),
}
Variants§
Static(&'static str)
Created from static data.
StaticAscii(&'static str)
Created from static data, known to contain only ASCII chars.
Owned(Box<str, Global>)
An owned chunk of data. Note that we use Box
rather than Vec
to avoid the
storage overhead.
Arc(Arc<str, Global>)
Implementations§
source§impl FastString
impl FastString
sourcepub const fn from_static(s: &'static str) -> Self
pub const fn from_static(s: &'static str) -> Self
Create a FastString
from a static string. The string may contain non-ASCII characters, and if
so, will take the slower path when used in v8.
sourcepub const fn ensure_static_ascii(s: &'static str) -> Self
pub const fn ensure_static_ascii(s: &'static str) -> Self
Create a FastString
from a static string. If the string contains non-ASCII characters, the compiler
will abort.
sourcepub fn into_cheap_copy(self) -> (Self, Self)
pub fn into_cheap_copy(self) -> (Self, Self)
Creates a cheap copy of this FastString
, potentially transmuting it to a faster form. Note that this
is not a clone operation as it consumes the old FastString
.
sourcepub fn try_clone(&self) -> Option<Self>
pub fn try_clone(&self) -> Option<Self>
If this FastString
is cheaply cloneable, returns a clone.
pub const fn try_static_ascii(&self) -> Option<&'static [u8]>
pub fn as_bytes(&self) -> &[u8] ⓘ
pub fn as_str(&self) -> &str
sourcepub fn v8<'a>(&self, scope: &mut HandleScope<'a>) -> Local<'a, String>
pub fn v8<'a>(&self, scope: &mut HandleScope<'a>) -> Local<'a, String>
Create a v8 string from this FastString
. If the string is static and contains only ASCII characters,
an external one-byte static is created.
sourcepub fn truncate(&mut self, index: usize)
pub fn truncate(&mut self, index: usize)
Truncates a FastString
value, possibly re-allocating or memcpy’ing. May be slow.
Trait Implementations§
source§impl AsRef<str> for FastString
impl AsRef<str> for FastString
source§impl Borrow<str> for FastString
impl Borrow<str> for FastString
source§impl Debug for FastString
impl Debug for FastString
source§impl Default for FastString
impl Default for FastString
source§impl From<Arc<str, Global>> for FastString
impl From<Arc<str, Global>> for FastString
FastString
can be made cheaply from Arc<str>
as we know it’s shared and don’t need to do an
ASCII check.
source§impl From<String> for FastString
impl From<String> for FastString
FastString
can be made cheaply from String
as we know it’s owned and don’t need to do an
ASCII check.
source§impl From<Url> for FastString
impl From<Url> for FastString
FastString
can be made cheaply from Url
as we know it’s owned and don’t need to do an
ASCII check.