Struct telegraph_rs::Telegraph[][src]

pub struct Telegraph { /* fields omitted */ }

Implementations

impl Telegraph[src]

pub fn new(short_name: &str) -> AccountBuilder[src]

Use this method to create a new Telegraph account or import an existing one.

Most users only need one account, but this can be useful for channel administrators who would like to keep individual author names and profile links for each of their channels.

On success, returns an Account object with the regular fields and an additional access_token field.

use telegraph_rs::Telegraph;

let account = Telegraph::new("short_name")
    .access_token("b968da509bb76866c35425099bc0989a5ec3b32997d55286c657e6994bbb")
    .create()
    .await?;

pub async fn create_page(
    &self,
    title: &str,
    content: &str,
    return_content: bool
) -> Result<Page>
[src]

Use this method to create a new Telegraph page. On success, returns a Page object.

if return_content is true, a content field will be returned in the Page object.

use telegraph_rs::{Telegraph, html_to_node};

let telegraph = Telegraph::new("author")
    .access_token("b968da509bb76866c35425099bc0989a5ec3b32997d55286c657e6994bbb")
    .create()
    .await?;

let page = telegraph.create_page("title", &html_to_node("<p>Hello, world!</p>"), false).await?;

pub fn edit_account_info(self) -> AccountBuilder[src]

Use this method to update information about a Telegraph account.

Pass only the parameters that you want to edit.

On success, returns an Account object with the default fields.

pub async fn edit_page(
    &self,
    path: &str,
    title: &str,
    content: &str,
    return_content: bool
) -> Result<Page>
[src]

Use this method to edit an existing Telegraph page.

On success, returns a Page object.

pub async fn get_account_info(&self, fields: &[&str]) -> Result<Account>[src]

Use this method to get information about a Telegraph account. Returns an Account object on success.

Available fields: short_name, author_name, author_url, auth_url, page_count.

pub async fn get_page(path: &str, return_content: bool) -> Result<Page>[src]

Use this method to get a Telegraph page. Returns a Page object on success.

pub async fn get_page_list(&self, offset: i32, limit: i32) -> Result<PageList>[src]

Use this method to get a list of pages belonging to a Telegraph account.

Returns a PageList object, sorted by most recently created pages first.

  • offset Sequential number of the first page to be returned. (suggest: 0)
  • limit Limits the number of pages to be retrieved. (suggest: 50)

pub async fn get_views(path: &str, time: &[i32]) -> Result<PageViews>[src]

Use this method to get the number of views for a Telegraph article.

Returns a PageViews object on success.

By default, the total number of page views will be returned.

use telegraph_rs::Telegraph;

let view1 = Telegraph::get_views("Sample-Page-12-15", &vec![2016, 12]).await?;
let view2 = Telegraph::get_views("Sample-Page-12-15", &vec![2019, 5, 19, 12]).await?; // year-month-day-hour

pub async fn revoke_access_token(&mut self) -> Result<Account>[src]

Use this method to revoke access_token and generate a new one,

for example, if the user would like to reset all connected sessions,

or you have reasons to believe the token was compromised.

On success, returns an Account object with new access_token and auth_url fields.

pub async fn upload<P: AsRef<Path>>(files: &[P]) -> Result<Vec<ImageInfo>>[src]

Upload files to telegraph

Trait Implementations

impl Debug for Telegraph[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.