Skip to main content

TokenTerm

Struct TokenTerm 

Source
pub struct TokenTerm(/* private fields */);
Expand description

Canonical term text. Valid UTF-16 is stored as a string; unpaired units remain exact.

Serialization uses a JSON string for scalar text or an explicit {"utf16":[...]} object for unpaired units. Scalar and raw-unit construction give identical identity for the same valid text.

use uqa_analysis::TokenTerm;
let term = TokenTerm::from_utf16(vec![0xd83d]);
assert!(term.as_str().is_none());
assert_eq!(term.utf16().as_ref(), [0xd83d]);
assert!(term.into_string().is_err());

Implementations§

Source§

impl TokenTerm

Source

pub fn clone_budgeted( &self, budget: &MemoryBudget, poll: impl FnMut() -> AnalysisResult<()>, ) -> AnalysisResult<Budgeted<Self>>

Copy this term into independently reserved storage without changing scalar or raw-unit identity.

Source

pub fn from_utf16_budgeted( input: Budgeted<Vec<u16>>, poll: impl FnMut() -> AnalysisResult<()>, ) -> AnalysisResult<Budgeted<Self>>

Consume reserved UTF-16 units, preserving isolated surrogates without replacement.

Valid input reserves the exact UTF-8 buffer before decoding and releases the UTF-16 lease only after freeing its buffer. The input must carry the reservation for its capacity. Cancellation is checked during both validation and conversion.

Source§

impl TokenTerm

Source

pub fn from_utf16(units: Vec<u16>) -> Self

Source

pub fn as_str(&self) -> Option<&str>

Source

pub fn utf16(&self) -> Cow<'_, [u16]>

Source

pub fn into_utf16(self) -> Vec<u16>

Source

pub fn into_string(self) -> AnalysisResult<String>

Project to a Unicode string, returning an error instead of replacing unpaired units.

Source

pub fn character_count(&self) -> usize

Count each scalar or isolated surrogate as one character.

Source

pub fn utf16_len(&self) -> usize

Trait Implementations§

Source§

impl Clone for TokenTerm

Source§

fn clone(&self) -> TokenTerm

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TokenTerm

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TokenTerm

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for TokenTerm

Source§

impl From<&str> for TokenTerm

Source§

fn from(value: &str) -> Self

Converts to this type from the input type.
Source§

impl From<String> for TokenTerm

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl Hash for TokenTerm

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TokenTerm

Source§

fn eq(&self, other: &TokenTerm) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<&str> for TokenTerm

Source§

fn eq(&self, other: &&str) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<str> for TokenTerm

Source§

fn eq(&self, other: &str) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for TokenTerm

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TokenTerm

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.