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
//! Sequence endpoint.

mod builder;
pub(crate) mod metadata;
pub(crate) mod service;

use bytes::Bytes;

use crate::Client;

pub use self::{builder::Builder, metadata::Metadata, service::Service};

/// A response from the sequence endpoint.
#[derive(Debug)]
pub struct Sequence {
    client: Client,
    id: String,
    sequence: Bytes,
}

impl Sequence {
    pub(crate) fn new(client: Client, id: String, sequence: Bytes) -> Self {
        Self {
            client,
            id,
            sequence,
        }
    }

    /// Returns the sequence.
    pub fn sequence(&self) -> Bytes {
        self.sequence.clone()
    }

    /// Builds a request to get the metadata related to the sequence.
    pub fn metadata(&self) -> metadata::Builder {
        metadata::Builder::new(self.client.clone(), &self.id)
    }
}