pub struct UserClient { /* private fields */ }Expand description
User client for interacting with user-related APIs
Implementations§
Source§impl UserClient
impl UserClient
Sourcepub fn new(http_client: HttpClient, token_getter: Arc<dyn TokenGetter>) -> Self
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
Sourcepub fn http_client(&self) -> &HttpClient
pub fn http_client(&self) -> &HttpClient
Get a reference to the internal HTTP client
Sourcepub async fn get_user_info(
&self,
vip_version: Option<&str>,
) -> NetDiskResult<UserInfo>
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
impl Clone for UserClient
Source§fn clone(&self) -> UserClient
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for UserClient
impl !RefUnwindSafe for UserClient
impl Send for UserClient
impl Sync for UserClient
impl Unpin for UserClient
impl UnsafeUnpin for UserClient
impl !UnwindSafe for UserClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more