pub struct UserClient { /* private fields */ }
Expand description
Provides access to user-related API endpoints.
This client allows you to fetch public information about Wattpad users.
Implementations§
Source§impl UserClient
impl UserClient
Sourcepub async fn get_user_info(
&self,
username: &str,
fields: Option<&[UserField]>,
) -> Result<UserResponse, WattpadError>
pub async fn get_user_info( &self, username: &str, fields: Option<&[UserField]>, ) -> Result<UserResponse, WattpadError>
Fetches detailed public information about a specific user.
This function retrieves a user’s profile data, such as their follower count, stories they’ve written, and more.
§Arguments
username
- The username of the user to fetch.fields
- An optional slice ofUserField
specifying which fields to retrieve. IfNone
, a default set of fields will be requested.
§Returns
A Result
containing a UserResponse
struct with the user’s data on success.
§Errors
Returns a WattpadError
if the network request fails, the API returns an error
(e.g., user not found), or a requested field requires authentication when the
client is unauthenticated.
§Examples
let client = WattpadClient::new();
let username = "test";
let fields = &[UserField::Username, UserField::FollowerCount];
let user_info = client.user.get_user_info(username, Some(fields)).await?;
println!("User: {}", user_info.username);
println!("Followers: {}", user_info.follower_count);
Auto Trait Implementations§
impl Freeze for UserClient
impl !RefUnwindSafe for UserClient
impl Send for UserClient
impl Sync for UserClient
impl Unpin 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