Skip to content
This repository was archived by the owner on Jun 2, 2023. It is now read-only.

Commit fe19dc8

Browse files
committed
add server member and user objects
1 parent 8533a70 commit fe19dc8

File tree

8 files changed

+86
-9
lines changed

8 files changed

+86
-9
lines changed

guilded/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! # gwilight
1+
//! # guilded
22
//!
3-
//! `gwilight` is a powerful, flexible, and scalable ecosystem of Rust libraries for the Guilded
3+
//! `guilded` is a powerful, flexible, and scalable ecosystem of Rust libraries for the Guilded
44
//! API.

http/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

model/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ edition = "2021"
88
license = "ISC"
99
repository = "https://github.com/HarTexTeam/guilded-rs"
1010
rust-version = "1.57.0"
11-
version = "0.1.0-dev.1"
11+
version = "0.1.0-dev.2"
1212

1313
[dependencies]
14-
uuid = { default-features = false, features = [ "v5" ], version = "0.8.2" }
1514
time = { default-features = false, features = [ "parsing", "std" ], version = "0.3.5" }
15+
uuid = { default-features = false, features = [ "v5" ], version = "0.8.2" }

model/src/id/marker.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ pub struct ChannelMarker;
1111

1212
/// A marker for document IDs.
1313
///
14-
/// Document IDs on guilded are unique numerical IDs (for example, `123456`).
14+
/// Document IDs on Guilded are unique numerical IDs (for example, `123456`).
1515
#[derive(Clone, Copy, Debug)]
1616
#[non_exhaustive]
1717
pub struct DocumentMarker;
1818

1919
/// A marker for forum thread IDs.
2020
///
21-
/// Forum thread IDs on guilded are unique numerical IDs (for example, `123456`).
21+
/// Forum thread IDs on Guilded are unique numerical IDs (for example, `123456`).
2222
#[derive(Clone, Copy, Debug)]
2323
#[non_exhaustive]
2424
pub struct ForumThreadMarker;
@@ -46,11 +46,15 @@ pub struct UserMarker;
4646

4747
/// A marker for reaction IDs.
4848
///
49-
/// Reaction IDs on guilded are unique numerical IDs (for example, `123456`).
49+
/// Reaction IDs on Guilded are unique numerical IDs (for example, `123456`).
5050
#[derive(Clone, Copy, Debug)]
5151
#[non_exhaustive]
5252
pub struct ReactionMarker;
5353

54+
#[derive(Clone, Copy, Debug)]
55+
#[non_exhaustive]
56+
pub struct RoleMarker;
57+
5458
/// A marker for server IDs.
5559
///
5660
/// Server IDs on Guilded are unique 8-character IDs (for example, `Ann6LewA`).

model/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
//! # gwilight_model
1+
//! # guilded_model
22
//!
3-
//! `gwilight_model` is a crate of models for the Guilded API.
3+
//! `guilded_model` is a crate of models for the Guilded API.
44
55
pub mod datetime;
66
pub mod docs;
@@ -9,3 +9,5 @@ pub mod id;
99
pub mod list;
1010
pub mod messaging;
1111
pub mod reactions;
12+
pub mod server;
13+
pub mod user;

model/src/server/member/mod.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//! The member object.
2+
3+
use crate::datetime::Timestamp;
4+
use crate::id::{marker::RoleMarker, Id};
5+
use crate::user::User;
6+
7+
/// Represents a server member.
8+
#[derive(Clone, Debug)]
9+
pub struct Member {
10+
user: User,
11+
role_ids: Vec<Id<RoleMarker>>,
12+
nickname: Option<String>,
13+
joined_at: Timestamp
14+
}
15+
16+
impl Member {
17+
pub fn user(&self) -> User {
18+
self.user.clone()
19+
}
20+
21+
pub fn role_ids(&self) -> Vec<Id<RoleMarker>> {
22+
self.role_ids.clone()
23+
}
24+
25+
pub fn nickname(&self) -> Option<&str> {
26+
self.nickname.as_deref()
27+
}
28+
29+
pub fn joined_at(&self) -> Timestamp {
30+
self.joined_at
31+
}
32+
}

model/src/server/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod member;

model/src/user/mod.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//! The user object.
2+
3+
use crate::datetime::Timestamp;
4+
use crate::id::{marker::UserMarker, Id};
5+
6+
#[derive(Clone, Debug)]
7+
pub struct User {
8+
id: Id<UserMarker>,
9+
r#type: UserType,
10+
name: String,
11+
created_at: Timestamp,
12+
}
13+
14+
impl User {
15+
pub fn id(&self) -> Id<UserMarker> {
16+
self.id.clone()
17+
}
18+
19+
pub fn r#type(&self) -> UserType {
20+
self.r#type.clone()
21+
}
22+
23+
pub fn name(&self) -> &str {
24+
self.name.as_ref()
25+
}
26+
27+
pub fn created_at(&self) -> Timestamp {
28+
self.created_at
29+
}
30+
}
31+
32+
/// Represents the type of a user.
33+
#[derive(Clone, Debug)]
34+
pub enum UserType {
35+
Bot,
36+
User
37+
}

0 commit comments

Comments
 (0)