diff --git a/guilded/src/lib.rs b/guilded/src/lib.rs index 7ae232e..5d76365 100644 --- a/guilded/src/lib.rs +++ b/guilded/src/lib.rs @@ -1,4 +1,4 @@ -//! # gwilight +//! # guilded //! -//! `gwilight` is a powerful, flexible, and scalable ecosystem of Rust libraries for the Guilded +//! `guilded` is a powerful, flexible, and scalable ecosystem of Rust libraries for the Guilded //! API. diff --git a/http/src/lib.rs b/http/src/lib.rs index e69de29..8b13789 100644 --- a/http/src/lib.rs +++ b/http/src/lib.rs @@ -0,0 +1 @@ + diff --git a/model/Cargo.toml b/model/Cargo.toml index 3d07fbb..a55a186 100644 --- a/model/Cargo.toml +++ b/model/Cargo.toml @@ -8,8 +8,8 @@ edition = "2021" license = "ISC" repository = "https://github.com/HarTexTeam/guilded-rs" rust-version = "1.57.0" -version = "0.1.0-dev.1" +version = "0.1.0-dev.2" [dependencies] -uuid = { default-features = false, features = [ "v5" ], version = "0.8.2" } time = { default-features = false, features = [ "parsing", "std" ], version = "0.3.5" } +uuid = { default-features = false, features = [ "v5" ], version = "0.8.2" } diff --git a/model/src/id/marker.rs b/model/src/id/marker.rs index 3b34562..70bcdd2 100644 --- a/model/src/id/marker.rs +++ b/model/src/id/marker.rs @@ -11,14 +11,14 @@ pub struct ChannelMarker; /// A marker for document IDs. /// -/// Document IDs on guilded are unique numerical IDs (for example, `123456`). +/// Document IDs on Guilded are unique numerical IDs (for example, `123456`). #[derive(Clone, Copy, Debug)] #[non_exhaustive] pub struct DocumentMarker; /// A marker for forum thread IDs. /// -/// Forum thread IDs on guilded are unique numerical IDs (for example, `123456`). +/// Forum thread IDs on Guilded are unique numerical IDs (for example, `123456`). #[derive(Clone, Copy, Debug)] #[non_exhaustive] pub struct ForumThreadMarker; @@ -46,11 +46,15 @@ pub struct UserMarker; /// A marker for reaction IDs. /// -/// Reaction IDs on guilded are unique numerical IDs (for example, `123456`). +/// Reaction IDs on Guilded are unique numerical IDs (for example, `123456`). #[derive(Clone, Copy, Debug)] #[non_exhaustive] pub struct ReactionMarker; +#[derive(Clone, Copy, Debug)] +#[non_exhaustive] +pub struct RoleMarker; + /// A marker for server IDs. /// /// Server IDs on Guilded are unique 8-character IDs (for example, `Ann6LewA`). diff --git a/model/src/lib.rs b/model/src/lib.rs index a5a8ad2..fc2b537 100644 --- a/model/src/lib.rs +++ b/model/src/lib.rs @@ -1,6 +1,6 @@ -//! # gwilight_model +//! # guilded_model //! -//! `gwilight_model` is a crate of models for the Guilded API. +//! `guilded_model` is a crate of models for the Guilded API. pub mod datetime; pub mod docs; @@ -9,3 +9,5 @@ pub mod id; pub mod list; pub mod messaging; pub mod reactions; +pub mod server; +pub mod user; diff --git a/model/src/server/member/mod.rs b/model/src/server/member/mod.rs new file mode 100644 index 0000000..1bef33f --- /dev/null +++ b/model/src/server/member/mod.rs @@ -0,0 +1,32 @@ +//! The member object. + +use crate::datetime::Timestamp; +use crate::id::{marker::RoleMarker, Id}; +use crate::user::User; + +/// Represents a server member. +#[derive(Clone, Debug)] +pub struct Member { + user: User, + role_ids: Vec>, + nickname: Option, + joined_at: Timestamp +} + +impl Member { + pub fn user(&self) -> User { + self.user.clone() + } + + pub fn role_ids(&self) -> Vec> { + self.role_ids.clone() + } + + pub fn nickname(&self) -> Option<&str> { + self.nickname.as_deref() + } + + pub fn joined_at(&self) -> Timestamp { + self.joined_at + } +} diff --git a/model/src/server/mod.rs b/model/src/server/mod.rs new file mode 100644 index 0000000..0dd2a03 --- /dev/null +++ b/model/src/server/mod.rs @@ -0,0 +1 @@ +pub mod member; diff --git a/model/src/user/mod.rs b/model/src/user/mod.rs new file mode 100644 index 0000000..38f7451 --- /dev/null +++ b/model/src/user/mod.rs @@ -0,0 +1,37 @@ +//! The user object. + +use crate::datetime::Timestamp; +use crate::id::{marker::UserMarker, Id}; + +#[derive(Clone, Debug)] +pub struct User { + id: Id, + r#type: UserType, + name: String, + created_at: Timestamp, +} + +impl User { + pub fn id(&self) -> Id { + self.id.clone() + } + + pub fn r#type(&self) -> UserType { + self.r#type.clone() + } + + pub fn name(&self) -> &str { + self.name.as_ref() + } + + pub fn created_at(&self) -> Timestamp { + self.created_at + } +} + +/// Represents the type of a user. +#[derive(Clone, Debug)] +pub enum UserType { + Bot, + User +}