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
use std::future::Future;

use aws_smithy_runtime_api::client::{orchestrator::HttpResponse, result::SdkError};
use bytes::Bytes;

use super::KinesisResponse;
/// An AWS Kinesis record type primarily to store the underlying aws crates' actual record `T`, and
/// to abstract the encoded length calculation.
pub trait Record {
    type T;

    /// Create a new instance of this record.
    fn new(payload_bytes: &Bytes, partition_key: &str) -> Self;

    /// Returns the encoded length of the record.
    fn encoded_length(&self) -> usize;

    /// Moves the contained record to the caller.
    fn get(self) -> Self::T;
}

/// Capable of sending records.
pub trait SendRecord {
    type T;
    type E;

    /// Sends the records.
    fn send(
        &self,
        records: Vec<Self::T>,
        stream_name: String,
    ) -> impl Future<Output = Result<KinesisResponse, SdkError<Self::E, HttpResponse>>> + Send;
}