Update docs

This commit is contained in:
Jonas Platte 2019-10-24 22:55:10 +02:00
parent 1af436b775
commit ce6937c1a0

View File

@ -166,11 +166,11 @@ pub mod typing;
/// An event that is malformed or otherwise invalid. /// An event that is malformed or otherwise invalid.
/// ///
/// When attempting to deserialize an `EventResult`, an error in the input data may cause /// When attempting to deserialize an [`EventResult`](enum.EventResult.html), an error in the input
/// deserialization to fail, or the JSON structure may be correct, but additional constraints /// data may cause deserialization to fail, or the JSON structure may be correct, but additional
/// defined in the matrix specification are not upheld. This type provides an error message and a /// constraints defined in the matrix specification are not upheld. This type provides an error
/// `serde_json::Value` representation of the invalid event, as well as a flag for which type of /// message and a `serde_json::Value` representation of the invalid event, as well as a flag for
/// error was encountered. /// which type of error was encountered.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct InvalidEvent { pub struct InvalidEvent {
message: String, message: String,
@ -216,8 +216,8 @@ impl Error for InvalidEvent {}
/// An error returned when attempting to create an event with data that would make it invalid. /// An error returned when attempting to create an event with data that would make it invalid.
/// ///
/// This type is similar to `InvalidEvent`, but used during the construction of a new event, as /// This type is similar to [`InvalidEvent`](struct.InvalidEvent.html), but used during the
/// opposed to deserialization of an existing event from JSON. /// construction of a new event, as opposed to deserialization of an existing event from JSON.
#[derive(Clone, Debug, PartialEq)] #[derive(Clone, Debug, PartialEq)]
pub struct InvalidInput(String); pub struct InvalidInput(String);
@ -229,9 +229,11 @@ impl Display for InvalidInput {
impl Error for InvalidInput {} impl Error for InvalidInput {}
/// See `TryFromRaw`. This trait is merely a convenience that can be implemented instead of /// See [`TryFromRaw`][try]. This trait is merely a convenience that is be implemented instead of
/// `TryFromRaw` to get a `TryFromRaw` implementation with slightly less code if the conversion /// [`TryFromRaw`][try] to get a [`TryFromRaw`][try] implementation with slightly less code if the
/// can't fail, that is, the raw type and `Self` are identical in definition. /// conversion can't fail, that is, the raw type and `Self` are identical in definition.
///
/// [try]: trait.TryFromRaw.html
pub trait FromRaw: Sized { pub trait FromRaw: Sized {
/// The raw type. /// The raw type.
type Raw: DeserializeOwned; type Raw: DeserializeOwned;
@ -240,9 +242,8 @@ pub trait FromRaw: Sized {
fn from_raw(_: Self::Raw) -> Self; fn from_raw(_: Self::Raw) -> Self;
} }
/// Types corresponding to some item in the matrix spec. Types that implement this trait need to /// Types corresponding to some item in the matrix spec. Types that implement this trait have a
/// have a corresponding 'raw' type, a potentially invalid representation that can be converted to /// corresponding 'raw' type, a potentially invalid representation that can be converted to `Self`.
/// `Self`.
pub trait TryFromRaw: Sized { pub trait TryFromRaw: Sized {
/// The raw type. /// The raw type.
type Raw: DeserializeOwned; type Raw: DeserializeOwned;
@ -266,8 +267,8 @@ impl<T: FromRaw> TryFromRaw for T {
/// ///
/// When data is successfully deserialized and validated, this structure will contain the /// When data is successfully deserialized and validated, this structure will contain the
/// deserialized value `T`. When deserialization succeeds, but the event is invalid for any reason, /// deserialized value `T`. When deserialization succeeds, but the event is invalid for any reason,
/// this structure will contain an `InvalidEvent`. See the documentation for `InvalidEvent` for /// this structure will contain an [`InvalidEvent`](struct.InvalidEvent.html). See the documentation
/// more details. /// for [`InvalidEvent`](struct.InvalidEvent.html) for more details.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub enum EventResult<T: TryFromRaw> { pub enum EventResult<T: TryFromRaw> {
/// `T` deserialized and validated successfully. /// `T` deserialized and validated successfully.
@ -275,7 +276,7 @@ pub enum EventResult<T: TryFromRaw> {
/// `T` failed either deserialization or validation. /// `T` failed either deserialization or validation.
/// ///
/// `InvalidEvent` contains the error message and the raw data. /// [`InvalidEvent`](struct.InvalidEvent.html) contains the error message and the raw data.
Err(InvalidEvent), Err(InvalidEvent),
} }