1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! Deserialization of Rust data structures.
//!
//! This module contains the `Deserialize` trait which is used to implement
//! deserialization of Rust data structures.
use cratePubNubError;
/// Trait for deserializing Rust data structures.
///
/// This trait is used to implement deserialization of Rust data structures.
/// It is used by the [`dx`] modules to deserialize the data returned by the
/// PubNub API.
///
/// To implement this trait, you must provide a `deserialize` method that
/// takes a `&[u8]` and returns a `Result<T, PubNubError>`.
/// If you want to provide your own deserializer, you have to implement this
/// trait over the [`dx`] selected by you in the Cargo.toml file.
///
/// Features and their results:
/// - `publish` - [`PublishResponseBody`]
/// - `access` - [`GrantTokenResponseBody`] and [`RevokeTokenResponseBody`]
///
/// More information about the response of the PubNub API can be found in the
/// [PubNub API Reference](https://www.pubnub.com/docs).
///
/// # Examples
/// ```
/// use pubnub::core::{Deserializer, PubNubError};
/// use pubnub::publish::PublishResult;
///
/// struct MyDeserializer;
///
/// impl Deserializer for MyDeserializer {
/// fn deserialize<PublishResult>(&self, bytes: &[u8]) -> Result<PublishResult, PubNubError> {
/// // ...
/// # unimplemented!()
/// }
/// }
/// ```
///
/// [`dx`]: ../dx/index.html
/// [`PublishResponseBody`]: ../../dx/publish/result/enum.PublishResponseBody.html
/// [`GrantTokenResponseBody`]: ../../dx/access/result/enum.GrantTokenResponseBody.html
/// [`RevokeTokenResponseBody`]: ../../dx/access/result/enum.RevokeTokenResponseBody.html