Skip to main content

Text

Struct Text 

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

A text node. Leaf only — cannot have children.

Implements Node but NOT ContainerNode or Element. Access text content via content() / set_content().

Implementations§

Source§

impl Text

Source

pub fn content(&self) -> String

Get the text content.

Source

pub fn set_content(&self, value: impl Into<String>)

Set the text content. No-op if value is unchanged.

Chrome: CharacterData::setData() — compares old vs new, skips if same. When text changes, marks parent for restyle + sets needs_layout.

Trait Implementations§

Source§

impl Clone for Text

Source§

fn clone(&self) -> Text

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Text

Source§

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

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

impl EventTarget for Text

Source§

fn on<E: Event>( &self, callback: impl FnMut(&E, &EventContext) + 'static, ) -> ListenerId

Add a typed event listener. Returns an ID for removal. Read more
Source§

fn on_with_options<E: Event>( &self, callback: impl FnMut(&E, &EventContext) + 'static, options: ListenerOptions, ) -> ListenerId

Add a listener with explicit options. Read more
Source§

fn on_capture<E: Event>( &self, callback: impl FnMut(&E, &EventContext) + 'static, ) -> ListenerId

Add a capture-phase listener. Read more
Source§

fn on_once<E: Event>( &self, callback: impl FnMut(&E, &EventContext) + 'static, ) -> ListenerId

Add a one-shot listener that auto-removes after first call.
Source§

fn off(&self, id: ListenerId)

Remove a listener by its ID.
Source§

fn dispatch_event(&self, event: &dyn Event) -> bool

Dispatch an event to this target. Read more
Source§

impl HasHandle for Text

Source§

fn handle(&self) -> Handle

Get the inner Handle for this node/target. Read more
Source§

impl Node for Text

Source§

fn is_alive(&self) -> bool

Check if this node is still alive in the document. Read more
Source§

fn parent(&self) -> Option<Handle>

Get the parent node, or None if this is the root or detached.
Source§

fn next_sibling(&self) -> Option<Handle>

Get the next sibling in the parent’s child list.
Source§

fn prev_sibling(&self) -> Option<Handle>

Get the previous sibling in the parent’s child list.
Source§

fn detach(&self)

Detach this node from its parent. The node stays alive but is no longer in the tree.
Source§

fn destroy(&self)

Destroy this node. Frees the slot — all handles to it become stale.
Source§

fn raw(&self) -> RawId

Get the raw ID for cross-thread communication. Read more
Source§

fn node_kind(&self) -> Option<NodeType>

Get the DOM node type (Element, Text, Document, etc.).
Source§

fn is_element(&self) -> bool

Is this an element node?
Source§

fn is_text(&self) -> bool

Is this a text node?
Source§

fn is_document(&self) -> bool

Is this the document root?
Source§

fn style(&self) -> StyleAccess

Per-property style access — like JavaScript’s element.style.
Source§

fn styled(self, f: impl FnOnce(&mut StyleAccess)) -> Self

Apply styles via closure and return self for chaining. Read more
Source§

impl Copy for Text

Auto Trait Implementations§

§

impl Freeze for Text

§

impl !RefUnwindSafe for Text

§

impl Send for Text

§

impl !Sync for Text

§

impl Unpin for Text

§

impl UnsafeUnpin for Text

§

impl !UnwindSafe for Text

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> MaybeBoxed<Box<T>> for T

Source§

fn maybe_boxed(self) -> Box<T>

Convert
Source§

impl<T> MaybeBoxed<T> for T

Source§

fn maybe_boxed(self) -> T

Convert
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> ErasedDestructor for T
where T: 'static,