Skip to main content

UserClient

Struct UserClient 

Source
pub struct UserClient { /* private fields */ }
Expand description

User client for interacting with user-related APIs

Implementations§

Source§

impl UserClient

Source

pub fn new(http_client: HttpClient, token_getter: Arc<dyn TokenGetter>) -> Self

Create a new UserClient instance

Usually you don’t need to call this directly - use BaiduNetDiskClient::user() instead

Source

pub fn http_client(&self) -> &HttpClient

Get a reference to the internal HTTP client

Source

pub async fn get_user_info( &self, vip_version: Option<&str>, ) -> NetDiskResult<UserInfo>

Get user information

§Arguments
  • vip_version - Optional vip_version parameter (set to “v2” to get real user identity)
§Returns

Returns UserInfo containing user details

§Examples
use baidu_netdisk_sdk::BaiduNetDiskClient;

let client = BaiduNetDiskClient::builder().build()?;
client.load_token_from_env()?;
let user_info = client.user().get_user_info(None).await?;
println!("VIP type: {}", user_info.vip_type);
Examples found in repository?
examples/user_info.rs (line 20)
5async fn main() -> Result<(), Box<dyn std::error::Error>> {
6    env_logger::init();
7
8    println!("=== Baidu NetDisk User Info Test ===\n");
9
10    let client = BaiduNetDiskClient::builder()
11        .app_key("your_app_key")
12        .app_secret("your_app_secret")
13        .build()?;
14    info!("Client created successfully");
15
16    client.load_token_from_env()?;
17    info!("Token loaded successfully");
18
19    println!("Getting user info...");
20    let user_info = client.user().get_user_info(Some("v2")).await?;
21
22    println!("\n=== User Information ===");
23    println!("Baidu Name:    {}", user_info.baidu_name);
24    println!("NetDisk Name:  {}", user_info.netdisk_name);
25    println!("Avatar URL:    {}", user_info.avatar_url);
26    println!(
27        "VIP Type:      {}",
28        match user_info.vip_type {
29            0 => "Regular user",
30            1 => "VIP member",
31            2 => "SVIP super member",
32            _ => "Unknown",
33        }
34    );
35    println!("User ID (uk):  {}", user_info.uk);
36
37    Ok(())
38}

Trait Implementations§

Source§

impl Clone for UserClient

Source§

fn clone(&self) -> UserClient

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 UserClient

Source§

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

Formats the value using the given formatter. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. 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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more