pub struct RawStr(/* private fields */);Expand description
Bytes UnityPy holds as a str. Valid UTF-8 or not; computed strings use
fallible shared storage, while input strings borrow their Bytes.
Implementations§
Source§impl RawStr
impl RawStr
Sourcepub fn new(bytes: impl Into<Bytes>) -> Self
pub fn new(bytes: impl Into<Bytes>) -> Self
Wraps bytes (a Vec, a boxed slice, a static slice or a shared buffer).
A slice of a file’s shared buffer, kept without a copy.
Sourcepub fn charged(bytes: &[u8], meter: &Arc<Meter>) -> Result<Self, ChargeError>
pub fn charged(bytes: &[u8], meter: &Arc<Meter>) -> Result<Self, ChargeError>
A string the core computes from an input (a decimal common-string
offset, a lower-cased name), charged to meter before it is
allocated: its buffer at heap_cost and the owner record
(crate::budget::OWNER_COST) that keeps the charge inside it, so
every clone counts until the last one drops. An empty string is
static and charges nothing.
Sourcepub fn charged_concat(
parts: &[&[u8]],
meter: &Arc<Meter>,
) -> Result<Self, ChargeError>
pub fn charged_concat( parts: &[&[u8]], meter: &Arc<Meter>, ) -> Result<Self, ChargeError>
The concatenation of parts (a resource candidate’s stem and its
suffix), computed and charged as Self::charged is: one buffer,
charged before it is allocated.
Sourcepub const fn from_static(bytes: &'static [u8]) -> Self
pub const fn from_static(bytes: &'static [u8]) -> Self
A static string (a common string, a constant name).
Sourcepub fn to_str(&self) -> Option<&str>
pub fn to_str(&self) -> Option<&str>
The string when the bytes are strict UTF-8 (overlong forms and encoded
surrogates are invalid, as CANONICAL_DUMP.md section 3 defines it).
Sourcepub fn into_bytes(self) -> Bytes
pub fn into_bytes(self) -> Bytes
The shared bytes, consuming the string. Computed strings need a
Bytes owner adapter here; name lookups and slices avoid that adapter.
Trait Implementations§
impl Eq for RawStr
Source§impl From<&str> for RawStr
impl From<&str> for RawStr
Source§fn from(s: &str) -> Self
fn from(s: &str) -> Self
Copies (use RawStr::from_static for a constant).