Struct Document

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

The Document interface represents any web page loaded in the browser and serves as an entry point into the web page’s content, which is the DOM tree.

(JavaScript docs)

Implementations§

Source§

impl Document

Source

pub fn create_document_fragment(&self) -> DocumentFragment

In an HTML document, the Document.createDocumentFragment() method creates a new empty DocumentFragment.

(JavaScript docs)

Source

pub fn create_element( &self, tag: &str, ) -> Result<Element, InvalidCharacterError>

In an HTML document, the Document.createElement() method creates the HTML element specified by tag, or an HTMLUnknownElement if tag isn’t recognized. In other documents, it creates an element with a null namespace URI.

(JavaScript docs)

Source

pub fn create_element_ns( &self, namespace_uri: &str, tag: &str, ) -> Result<Element, CreateElementNsError>

Creates an element with the specified namespace URI and qualified name. To create an element without specifying a namespace URI, use the createElement method.

(JavaScript docs)

Source

pub fn create_text_node(&self, text: &str) -> TextNode

Creates a new text node.

(JavaScript docs)

Source

pub fn location(&self) -> Option<Location>

Returns a Location object which contains information about the URL of the document and provides methods for changing that URL and loading another URL.

(JavaScript docs)

Source

pub fn body(&self) -> Option<HtmlElement>

Returns the <body> or <frameset> node of the current document, or null if no such element exists.

(JavaScript docs)

Source

pub fn head(&self) -> Option<HtmlElement>

Returns the <head> element of the current document. If there are more than one <head> elements, the first one is returned.

(JavaScript docs)

Source

pub fn title(&self) -> String

Gets the title of the document.

(JavaScript docs)

Source

pub fn set_title(&self, title: &str)

Sets the title of the document.

(JavaScript docs)

Source

pub fn document_element(&self) -> Option<Element>

Returns the Element that is the root element of the document (for example, the <html> element for HTML documents).

(JavaScript docs)

Source

pub fn pointer_lock_element(&self) -> Option<Element>

Returns the Element that the pointer is locked to, if it is locked to any

(JavaScript docs)

Source

pub fn exit_pointer_lock(&self)

Exit the pointer lock on the current element

(JavaScript docs)

Source

pub fn import_node<N: INode>( &self, n: &N, kind: CloneKind, ) -> Result<Node, NotSupportedError>

Import node from another document

(JavaScript docs)

Source

pub fn fullscreen_enabled(&self) -> bool

Check if the fullscreen API is enabled

(JavaScript docs)

Source

pub fn fullscreen_element(&self) -> Option<Element>

Get the current fullscreen element, or None if there is nothing fullscreen

(JavaScript docs)

Trait Implementations§

Source§

impl AsRef<Reference> for Document

Source§

fn as_ref(&self) -> &Reference

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Document

Source§

fn clone(&self) -> Document

Returns a copy 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 Document

Source§

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

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

impl From<Document> for EventTarget

Source§

fn from(value: Document) -> Self

Converts to this type from the input type.
Source§

impl From<Document> for Node

Source§

fn from(value: Document) -> Self

Converts to this type from the input type.
Source§

impl From<Document> for Reference

Source§

fn from(value: Document) -> Self

Converts to this type from the input type.
Source§

impl IEventTarget for Document

Source§

fn add_event_listener<T, F>(&self, listener: F) -> EventListenerHandle
where T: ConcreteEvent, F: FnMut(T) + 'static,

Adds given event handler to the list of event listeners for the specified EventTarget on which it’s called. Read more
Source§

fn dispatch_event<T: IEvent>(&self, event: &T) -> Result<bool, TODO>

Dispatches an Event at this EventTarget, invoking the affected event listeners in the appropriate order. Read more
Source§

impl INode for Document

Source§

fn as_node(&self) -> &Node

Casts a reference to this object into a reference to a Node.
Source§

fn append_child<T: INode>(&self, child: &T)

Adds a node to the end of the list of children of a specified parent node. Read more
Source§

fn remove_child<T: INode>(&self, child: &T) -> Result<Node, NotFoundError>

Removes a child node from the DOM. Read more
Source§

fn clone_node(&self, kind: CloneKind) -> Result<Self, TODO>

Returns a duplicate of the node on which this method was called. Read more
Source§

fn contains<T: INode>(&self, node: &T) -> bool

Checks whenever a given node is a descendant of this one or not. Read more
Source§

fn insert_before<T: INode, U: INode>( &self, new_node: &T, reference_node: &U, ) -> Result<Node, InsertNodeError>

Inserts the specified node before the reference node as a child of the current node. Read more
Source§

fn replace_child<T: INode, U: INode>( &self, new_child: &T, old_child: &U, ) -> Result<Node, InsertNodeError>

Replaces one hild node of the specified node with another. Read more
Source§

fn parent_node(&self) -> Option<Node>

Returns the parent of this node in the DOM tree. Read more
Source§

fn first_child(&self) -> Option<Node>

Returns the node’s first child in the tree, or None if the node is childless. Read more
Source§

fn last_child(&self) -> Option<Node>

Returns the node’s last child in the tree, or None if the node is childless. Read more
Source§

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

Returns the node’s next sibling in the tree, or None if there isn’t such a node. Read more
Source§

fn node_name(&self) -> String

Returns the name of the node. Read more
Source§

fn node_type(&self) -> NodeType

Returns the type of the node. Read more
Source§

fn node_value(&self) -> Option<String>

Returns the value of the node. Read more
Source§

fn set_node_value(&self, value: Option<&str>)

Sets the value of the node. Read more
Source§

fn owner_document(&self) -> Option<Document>

Returns the Document that this node belongs to. Read more
Source§

fn parent_element(&self) -> Option<Element>

Returns an Element that is the parent of this node. Returns null if the node has no parent or the parent is not an Element. Read more
Source§

fn previous_sibling(&self) -> Option<Node>

Returns the node’s previous sibling in the tree, or None if there isn’t such a node. Read more
Source§

fn text_content(&self) -> Option<String>

A property which represents the text content of a node and its descendants. Read more
Source§

fn set_text_content(&self, text: &str)

Sets the text content of this node; calling thil removes all of node’s children and replaces them with a single text node with the given value. Read more
Source§

fn child_nodes(&self) -> NodeList

Returns a live collection of child nodes of this node. Read more
Source§

fn base_uri(&self) -> String

Gets the base URL. Read more
Source§

fn has_child_nodes(&self) -> bool

Returns whether this node has children nodes. Read more
Source§

fn is_default_namespace(&self, namespace: &str) -> bool

Determines whether the given namespace is the default namespace of this node. Read more
Source§

fn is_equal_node<T: INode>(&self, node: &T) -> bool

Tests whether this node is equal to another node. Two nodes are equal if they have the same type, defining characteristics, matching attributes, and so on. Read more
Source§

fn is_same_node<T: INode>(&self, node: &T) -> bool

Test whether two Node references are the same. Read more
Source§

fn lookup_prefix(&self, namespace: &str) -> Option<String>

Returns the prefix for the given namespace URI, if present. Read more
Source§

fn lookup_namespace_uri(&self, prefix: &str) -> Option<String>

Returns the namespace URI for the given prefix. Read more
Source§

fn normalize(&self)

Merges any adjacent text nodes and removes empty text nodes under this node. Read more
Source§

impl INonElementParentNode for Document

Source§

fn get_element_by_id(&self, id: &str) -> Option<Element>

Returns a reference to the element by its ID; the ID is a string which can be used to uniquely identify the element, found in the HTML id attribute. Read more
Source§

impl IParentNode for Document

Source§

fn query_selector(&self, selector: &str) -> Result<Option<Element>, SyntaxError>

Returns the first element that is a descendant of the element on which it is invoked that matches the specified group of selectors. Read more
Source§

fn query_selector_all(&self, selector: &str) -> Result<NodeList, SyntaxError>

Returns a non-live NodeList of all elements descended from the element on which it is invoked that matches the specified group of CSS selectors. Read more
Source§

impl InstanceOf for Document

Source§

fn instance_of(reference: &Reference) -> bool

Checks whenever a given Reference if of type Self.
Source§

impl PartialEq for Document

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ReferenceType for Document

Source§

unsafe fn from_reference_unchecked(reference: Reference) -> Self

Converts a given reference into a concrete reference-like wrapper. Doesn’t do any type checking; highly unsafe to use!
Source§

impl<'_r> TryFrom<&'_r Reference> for Document

Source§

type Error = ConversionError

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

fn try_from(reference: &Reference) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'_r> TryFrom<&'_r Value> for Document

Source§

type Error = ConversionError

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

fn try_from(value: &Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Document> for Reference

Source§

type Error = Void

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

fn try_from(value: Document) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<EventTarget> for Document

Source§

type Error = ConversionError

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

fn try_from(value: EventTarget) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Node> for Document

Source§

type Error = ConversionError

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

fn try_from(value: Node) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Reference> for Document

Source§

type Error = ConversionError

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

fn try_from(reference: Reference) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Document

Source§

type Error = ConversionError

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

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for Document

Source§

impl JsSerialize for Document

Source§

impl StructuralPartialEq for Document

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