Skip to main content

Pagination

Struct Pagination 

Source
pub struct Pagination {
    pub current_page: u32,
    pub total_pages: Option<u32>,
    pub prev_url: Option<String>,
    pub next_url: Option<String>,
    pub first_url: Option<String>,
    pub last_url: Option<String>,
    pub page_urls: Vec<PageUrl>,
    pub pagination_type: PaginationType,
    pub has_infinite_scroll: bool,
    pub has_load_more: bool,
    pub items_per_page: Option<u32>,
    pub total_items: Option<u32>,
}
Expand description

分页信息

表示从 HTML 文档中提取的完整分页导航信息。

Fields§

§current_page: u32

当前页码

§total_pages: Option<u32>

总页数(部分分页模式可能无法获取)

§prev_url: Option<String>

上一页 URL

§next_url: Option<String>

下一页 URL

§first_url: Option<String>

第一页 URL

§last_url: Option<String>

最后一页 URL

§page_urls: Vec<PageUrl>

所有分页链接列表

§pagination_type: PaginationType

分页类型

§has_infinite_scroll: bool

是否使用无限滚动

§has_load_more: bool

是否使用「加载更多」

§items_per_page: Option<u32>

每页条目数(如可推断)

§total_items: Option<u32>

总条目数(如可获取)

Implementations§

Source§

impl Pagination

Source

pub fn none() -> Self

创建默认的 Pagination(无分页)

Source

pub fn has_pagination(&self) -> bool

判断该页面是否有分页导航

Source

pub fn next_page_url(&self) -> Option<&str>

返回下一页的 URL

Source

pub fn prev_page_url(&self) -> Option<&str>

返回上一页的 URL

Source

pub fn numbered_pages(&self) -> Vec<&PageUrl>

获取所有数字分页链接(排除上一页/下一页)

Trait Implementations§

Source§

impl Clone for Pagination

Source§

fn clone(&self) -> Pagination

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Pagination

Source§

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

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

impl Default for Pagination

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for Pagination

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Pagination

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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.