Struct Elements

Source
pub struct Elements<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> Elements<'a>

Source

pub fn new() -> Self

Source

pub fn with_nodes(nodes: Vec<BoxDynElement<'a>>) -> Self

Source

pub fn with_capacity(size: usize) -> Self

Source

pub fn get(&self, index: usize) -> Option<&BoxDynElement<'a>>

Source

pub fn get_ref(&self) -> &Vec<BoxDynElement<'a>>

Source§

impl<'a> Elements<'a>

Source

pub fn for_each<F>(&mut self, handle: F) -> &mut Self
where F: FnMut(usize, &mut BoxDynElement<'_>) -> bool,

Source

pub fn each<F>(&mut self, handle: F) -> &mut Self
where F: FnMut(usize, &mut BoxDynElement<'_>) -> bool,

Source

pub fn map<F, T: Sized>(&self, handle: F) -> Vec<T>
where F: Fn(usize, &BoxDynElement<'_>) -> T,

Source

pub fn length(&self) -> usize

pub fn length

Source

pub fn is_empty(&self) -> bool

pub fn is_empty

Source

pub fn document(&self) -> MaybeDoc

pub fn document, a quick way to get document

Source§

impl<'a> Elements<'a>

Source

pub fn prev(&self, selector: &str) -> Elements<'a>

Source

pub fn prev_all(&self, selector: &str) -> Elements<'a>

Source

pub fn prev_until( &self, selector: &str, filter: &str, contains: bool, ) -> Elements<'a>

Source

pub fn next(&self, selector: &str) -> Elements<'a>

Source

pub fn next_all(&self, selector: &str) -> Elements<'a>

Source

pub fn next_until( &self, selector: &str, filter: &str, contains: bool, ) -> Elements<'a>

Source

pub fn siblings(&self, selector: &str) -> Elements<'a>

Source

pub fn children(&self, selector: &str) -> Elements<'a>

Source

pub fn parent(&self, selector: &str) -> Elements<'a>

Source

pub fn parents(&self, selector: &str) -> Elements<'a>

Source

pub fn parents_until( &self, selector: &str, filter: &str, contains: bool, ) -> Elements<'a>

Source

pub fn closest(&self, selector: &str) -> Elements<'a>

Source

pub fn find(&self, selector: &str) -> Elements<'a>

pub fn find get elements by selector, support most of css selectors

Source

pub fn cloned(&self) -> Elements<'a>

Source

pub fn filter(&self, selector: &str) -> Elements<'a>

Source

pub fn filter_by<F>(&self, handle: F) -> Elements<'a>
where F: Fn(usize, &BoxDynElement<'_>) -> bool,

Source

pub fn filter_in(&self, search: &Elements<'_>) -> Elements<'a>

Source

pub fn is(&self, selector: &str) -> bool

Source

pub fn is_by<F>(&self, handle: F) -> bool
where F: Fn(usize, &BoxDynElement<'_>) -> bool,

Source

pub fn is_in(&self, search: &Elements<'_>) -> bool

Source

pub fn is_all(&self, selector: &str) -> bool

Source

pub fn is_all_by<F>(&self, handle: F) -> bool
where F: Fn(usize, &BoxDynElement<'_>) -> bool,

Source

pub fn is_all_in(&self, search: &Elements<'_>) -> bool

Source

pub fn not(&self, selector: &str) -> Elements<'a>

Source

pub fn not_by<F>(&self, handle: F) -> Elements<'a>
where F: Fn(usize, &BoxDynElement<'_>) -> bool,

Source

pub fn not_in(&self, search: &Elements<'_>) -> Elements<'a>

pub fn not_in remove element from Self which is also in search

Source

pub fn has(&self, selector: &str) -> Elements<'a>

Source

pub fn has_in(&self, search: &Elements<'_>) -> Elements<'a>

Source§

impl<'a> Elements<'a>

Source

pub fn eq(&self, index: usize) -> Elements<'a>

pub fn eq get a element by index

Source

pub fn first(&self) -> Elements<'a>

pub fn first get the first element, alias for ‘eq(0)’

Source

pub fn last(&self) -> Elements<'a>

pub fn last get the last element, alias for ‘eq(len - 1)’

Source

pub fn slice<T: RangeBounds<usize>>(&self, range: T) -> Elements<'a>

pub fn slice get elements by a range parameter slice(0..1) equal to eq(0), first

Source

pub fn add(&self, eles: Elements<'a>) -> Elements<'a>

pub fn add concat two element set to a new set, it will take the owership of the parameter element set, but no sence to Self

Source§

impl<'a> Elements<'a>

Source

pub fn text(&self) -> &str

pub fn text get the text of each element in the set

Source

pub fn set_text(&mut self, content: &str) -> &mut Self

pub fn set_text set each element’s text to content

Source

pub fn html(&self) -> &str

pub fn html get the first element’s html

Source

pub fn set_html(&mut self, content: &str) -> &mut Self

pub fn set_html set each element’s html to content

Source

pub fn outer_html(&self) -> &str

pub fn outer_html get the first element’s outer html

Source

pub fn texts(&self, limit_depth: u32) -> Texts<'a>

pub fn texts get the text node of each element

Source§

impl<'a> Elements<'a>

Source

pub fn attr(&self, attr_name: &str) -> Option<IAttrValue>

pub fn attr get the first element’s attribute value

Source

pub fn set_attr(&mut self, attr_name: &str, value: Option<&str>) -> &mut Self

pub fn set_attr set each element’s attribute to key = attr_name, value = value.

Source

pub fn remove_attr(&mut self, attr_name: &str) -> &mut Self

pub fn remove_attr

Source

pub fn has_class(&self, class_name: &str) -> bool

pub fn has_class

Source

pub fn add_class(&mut self, class_name: &str) -> &mut Self

pub fn add_class

Source

pub fn remove_class(&mut self, class_name: &str) -> &mut Self

pub fn remove_class

Source

pub fn toggle_class(&mut self, class_name: &str) -> &mut Self

pub fn toggle_class

Source§

impl<'a> Elements<'a>

Source

pub fn remove(self)

pub fn remove

Source

pub fn empty(&mut self) -> &mut Self

Source

pub fn append(&mut self, elements: &mut Elements<'_>) -> &mut Self

pub fn append

Source

pub fn append_to(&mut self, elements: &mut Elements<'_>) -> &mut Self

pub fn append_to

Source

pub fn prepend(&mut self, elements: &mut Elements<'_>) -> &mut Self

pub fn prepend

Source

pub fn prepend_to(&mut self, elements: &mut Elements<'_>) -> &mut Self

pub fn prepend_to

Source

pub fn insert_before(&mut self, elements: &mut Elements<'_>) -> &mut Self

pub fn insert_before

Source

pub fn before(&mut self, elements: &mut Elements<'_>) -> &mut Self

pub fn before

Source

pub fn insert_after(&mut self, elements: &mut Elements<'_>) -> &mut Self

pub fn insert_after

Source

pub fn after(&mut self, elements: &mut Elements<'_>) -> &mut Self

pub fn after

Trait Implementations§

Source§

impl<'a> Default for Elements<'a>

Source§

fn default() -> Elements<'a>

Returns the “default value” for a type. Read more
Source§

impl<'a> From<Vec<Box<dyn IElementTrait + 'a>>> for Elements<'a>

Source§

fn from(nodes: Vec<BoxDynElement<'a>>) -> Self

Converts to this type from the input type.
Source§

impl<'a> IntoIterator for Elements<'a>

Source§

type Item = Box<dyn IElementTrait + 'a>

The type of the elements being iterated over.
Source§

type IntoIter = Box<dyn Iterator<Item = <Elements<'a> as IntoIterator>::Item> + 'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Elements<'a>

§

impl<'a> !RefUnwindSafe for Elements<'a>

§

impl<'a> !Send for Elements<'a>

§

impl<'a> !Sync for Elements<'a>

§

impl<'a> Unpin for Elements<'a>

§

impl<'a> !UnwindSafe for Elements<'a>

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