Skip to main content

SpanOutput

Struct SpanOutput 

Source
#[repr(C)]
pub struct SpanOutput { pub text: *const u8, pub text_len: u32, pub spans: *const Span, pub span_count: u32, pub extra_data: *const u8, pub extra_data_len: u32, pub utf16_offsets: *const u32, pub utf16_offsets_len: u32, }
Expand description

Span 输出(包含文本、span 数组和额外数据) 注意:不实现 Clone / Copy,防止双份指针导致 double-free

Fields§

§text: *const u8

全文纯文本(所有 span 的 offset/len 索引此 buffer 的子串)

§text_len: u32§spans: *const Span

Span 数组

§span_count: u32§extra_data: *const u8

额外数据区(链接 URL、图片 URL 等)

§extra_data_len: u32§utf16_offsets: *const u32

可选:与 spans 一一对应的 UTF-16 偏移(指针为 null 表示未启用) 用于 iOS(NSString)/Android(SpannableString) 等 UTF-16 平台的零拷贝偏移转换

§utf16_offsets_len: u32

Implementations§

Source§

impl SpanOutput

Source

pub unsafe fn from_buffers(text: &[u8], spans: &[Span], extra: &[u8]) -> Self

从拥有的数据创建 SpanOutput(用于测试和内部使用) 调用者必须保持这些 buffer 存活

Trait Implementations§

Source§

impl Debug for SpanOutput

Source§

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

Formats the value using the given formatter. Read more

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> 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, 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.