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
impl TokenTerm
Sourcepub fn clone_budgeted(
&self,
budget: &MemoryBudget,
poll: impl FnMut() -> AnalysisResult<()>,
) -> AnalysisResult<Budgeted<Self>>
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.
Sourcepub fn from_utf16_budgeted(
input: Budgeted<Vec<u16>>,
poll: impl FnMut() -> AnalysisResult<()>,
) -> AnalysisResult<Budgeted<Self>>
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
impl TokenTerm
pub fn from_utf16(units: Vec<u16>) -> Self
pub fn as_str(&self) -> Option<&str>
pub fn utf16(&self) -> Cow<'_, [u16]>
pub fn into_utf16(self) -> Vec<u16>
Sourcepub fn into_string(self) -> AnalysisResult<String>
pub fn into_string(self) -> AnalysisResult<String>
Project to a Unicode string, returning an error instead of replacing unpaired units.
Sourcepub fn character_count(&self) -> usize
pub fn character_count(&self) -> usize
Count each scalar or isolated surrogate as one character.