diff --git a/src/event_id.rs b/src/event_id.rs index aa95f931..77d31857 100644 --- a/src/event_id.rs +++ b/src/event_id.rs @@ -9,6 +9,9 @@ use crate::{error::Error, parse_id, validate_id}; /// An `EventId` is generated randomly or converted from a string slice, and can be converted back /// into a string as needed. /// +/// It is discouraged to use this type directly – instead use one of the aliases (`EventId` and +/// `EventIdRef`) in the crate root. +/// /// # Room versions /// /// Matrix specifies multiple [room versions](https://matrix.org/docs/spec/#room-versions) and the diff --git a/src/lib.rs b/src/lib.rs index ae770d04..2fa264cb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -34,33 +34,71 @@ pub mod room_version_id; pub mod user_id; /// An owned event ID. +/// +/// Can be created via `new` (if the `rand` feature is enabled) and `TryFrom` + +/// `TryFrom<&str>`, implements `Serialize` and `Deserialize` if the `serde` feature is enabled. pub type EventId = event_id::EventId>; + /// A reference to an event ID. +/// +/// Can be created via `TryFrom<&str>`, implements `Serialize` if the `serde` feature is enabled. pub type EventIdRef<'a> = event_id::EventId<&'a str>; /// An owned room alias ID. +/// +/// Can be created via `TryFrom` and `TryFrom<&str>`, implements `Serialize` and +/// `Deserialize` if the `serde` feature is enabled. pub type RoomAliasId = room_alias_id::RoomAliasId>; + /// A reference to a room alias ID. +/// +/// Can be created via `TryFrom<&str>`, implements `Serialize` if the `serde` feature is enabled. pub type RoomAliasIdRef<'a> = room_alias_id::RoomAliasId<&'a str>; /// An owned room ID. +/// +/// Can be created via `new` (if the `rand` feature is enabled) and `TryFrom` + +/// `TryFrom<&str>`, implements `Serialize` and `Deserialize` if the `serde` feature is enabled. pub type RoomId = room_id::RoomId>; + /// A reference to a room ID. +/// +/// Can be created via `TryFrom<&str>`, implements `Serialize` if the `serde` feature is enabled. pub type RoomIdRef<'a> = room_id::RoomId<&'a str>; /// An owned room alias ID or room ID. +/// +/// Can be created via `TryFrom`, `TryFrom<&str>`, `From` and `From`; +/// implements `Serialize` and `Deserialize` if the `serde` feature is enabled. pub type RoomIdOrAliasId = room_id_or_room_alias_id::RoomIdOrAliasId>; + /// A reference to a room alias ID or room ID. +/// +/// Can be created via `TryFrom<&str>`, `From` and `From`; implements +/// `Serialize` if the `serde` feature is enabled. pub type RoomIdOrAliasIdRef<'a> = room_id_or_room_alias_id::RoomIdOrAliasId<&'a str>; /// An owned room version ID. +/// +/// Can be created using the `version_N` constructor functions, `TryFrom` and +/// `TryFrom<&str>`; implements `Serialize` and `Deserialize` if the `serde` feature is enabled. pub type RoomVersionId = room_version_id::RoomVersionId>; + /// A reference to a room version ID. +/// +/// Can be created using the `version_N` constructor functions and via `TryFrom<&str>`, implements +/// `Serialize` if the `serde` feature is enabled. pub type RoomVersionIdRef<'a> = room_version_id::RoomVersionId<&'a str>; /// An owned user ID. +/// +/// Can be created via `new` (if the `rand` feature is enabled) and `TryFrom` + +/// `TryFrom<&str>`, implements `Serialize` and `Deserialize` if the `serde` feature is enabled. pub type UserId = user_id::UserId>; + /// A reference to a user ID. +/// +/// Can be created via `TryFrom<&str>`, implements `Serialize` if the `serde` feature is enabled. pub type UserIdRef<'a> = user_id::UserId<&'a str>; /// All identifiers must be 255 bytes or less. diff --git a/src/room_alias_id.rs b/src/room_alias_id.rs index d8358631..b18ccc00 100644 --- a/src/room_alias_id.rs +++ b/src/room_alias_id.rs @@ -6,6 +6,9 @@ use crate::{error::Error, parse_id}; /// A Matrix room alias ID. /// +/// It is discouraged to use this type directly – instead use one of the aliases (`RoomAliasId` and +/// `RoomAliasIdRef`) in the crate root. +/// /// A `RoomAliasId` is converted from a string slice, and can be converted back into a string as /// needed. /// diff --git a/src/room_id.rs b/src/room_id.rs index 82a4416a..07fdfee6 100644 --- a/src/room_id.rs +++ b/src/room_id.rs @@ -9,6 +9,9 @@ use crate::{error::Error, parse_id}; /// A `RoomId` is generated randomly or converted from a string slice, and can be converted back /// into a string as needed. /// +/// It is discouraged to use this type directly – instead use one of the aliases (`RoomId` and +/// `RoomIdRef`) in the crate root. +/// /// ``` /// # use std::convert::TryFrom; /// # use ruma_identifiers::RoomId; diff --git a/src/room_id_or_room_alias_id.rs b/src/room_id_or_room_alias_id.rs index 67c93c80..5e1dcf0c 100644 --- a/src/room_id_or_room_alias_id.rs +++ b/src/room_id_or_room_alias_id.rs @@ -10,6 +10,9 @@ use crate::{error::Error, parse_id, room_alias_id::RoomAliasId, room_id::RoomId} /// from a string slice, and can be converted back into a string as needed. When converted from a /// string slice, the variant is determined by the leading sigil character. /// +/// It is discouraged to use this type directly – instead use one of the aliases +/// (`RoomIdOrRoomAliasId` and `RoomIdOrRoomAliasIdRef`) in the crate root. +/// /// ``` /// # use std::convert::TryFrom; /// # use ruma_identifiers::RoomIdOrAliasId; diff --git a/src/room_version_id.rs b/src/room_version_id.rs index 9b7239e1..742b2cc8 100644 --- a/src/room_version_id.rs +++ b/src/room_version_id.rs @@ -19,6 +19,9 @@ const MAX_CODE_POINTS: usize = 32; /// A `RoomVersionId` can be or converted or deserialized from a string slice, and can be converted /// or serialized back into a string as needed. /// +/// It is discouraged to use this type directly – instead use one of the aliases (`RoomVersionId` +/// and `RoomVersionIdRef`) in the crate root. +/// /// ``` /// # use std::convert::TryFrom; /// # use ruma_identifiers::RoomVersionId; diff --git a/src/user_id.rs b/src/user_id.rs index f4b2962c..2e8cb77c 100644 --- a/src/user_id.rs +++ b/src/user_id.rs @@ -9,6 +9,9 @@ use crate::{error::Error, is_valid_server_name, parse_id}; /// A `UserId` is generated randomly or converted from a string slice, and can be converted back /// into a string as needed. /// +/// It is discouraged to use this type directly – instead use one of the aliases (`UserId` and +/// `UserIdRef`) in the crate root. +/// /// ``` /// # use std::convert::TryFrom; /// # use ruma_identifiers::UserId;