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
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
//! Types used by [`crate::Transport`].

use crate::data::channel;
use crate::data::object::Object;
use crate::data::presence;
use crate::data::timetoken::Timetoken;
use crate::data::uuid::UUID;
use std::marker::PhantomData;

/// A request to publish a message to a channel.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Publish {
    /// A channel name to publish the message to.
    pub channel: channel::Name,

    /// The body of the message.
    pub payload: Object,

    /// Additional information associated with the message.
    pub meta: Option<Object>,
}

/// Subscribe to messages on channels and/or channel groups.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Subscribe {
    /// The channel names you are subscribing to.
    pub channels: Vec<channel::Name>,

    /// The channel group names you are subscribing to.
    pub channel_groups: Vec<channel::Name>,

    /// A timetoken to use.
    /// tt: 0 (zero) for the initial subscribe, or a valid timetoken if
    /// resuming / continuing / fast-forwarding from a previous subscribe flow.
    /// tr: Region as returned from the initial call with tt=0.
    pub timetoken: Timetoken,
}

/// Set state for a user for channels and/or channel groups.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SetState {
    /// The channel names to set state for.
    pub channels: Vec<channel::Name>,

    /// The channel group names to set state for.
    pub channel_groups: Vec<channel::Name>,

    /// The User UUID to set state for.
    pub uuid: UUID,

    /// State to set.
    pub state: Object,
}

/// Get state for a user for channels and/or channel groups.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct GetState {
    /// The channel names to get the state for.
    pub channels: Vec<channel::Name>,

    /// The channel group names to get state for.
    pub channel_groups: Vec<channel::Name>,

    /// The User UUID to get state for.
    pub uuid: UUID,
}

/// Retrieve UUID and State Information for subscribed devices on a specific
/// channel.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HereNow<TRespondWith>
where
    TRespondWith: presence::respond_with::RespondWith,
{
    /// The channel names to get the state for.
    pub channels: Vec<channel::Name>,

    /// The channel group names to get state for.
    pub channel_groups: Vec<channel::Name>,

    /// Type that specializes the response type.
    pub respond_with: PhantomData<TRespondWith>,
}

/// Retrieve UUID and State Information for subscribed devices on a all
/// channels.
#[allow(missing_copy_implementations)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct GlobalHereNow<TRespondWith>
where
    TRespondWith: presence::respond_with::RespondWith,
{
    /// Type that specializes the response type.
    pub respond_with: PhantomData<TRespondWith>,
}

/// Get list of channels user is present in.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct WhereNow {
    /// The User UUID to get list of channels for.
    pub uuid: UUID,
}