Skip to main content

neptunium_http/endpoints/channel/
get_stream_preview_image.rs

1use bon::Builder;
2use reqwest::Method;
3
4use crate::{
5    endpoints::{Endpoint, ResponseBody},
6    request::Request,
7};
8
9#[derive(Builder, Clone, Debug)]
10pub struct GetStreamPreviewImage {
11    pub stream_key: String,
12}
13
14/// The bytes of a JPEG image.
15#[derive(Clone, Debug)]
16pub struct StreamPreviewImageResponse(pub Vec<u8>);
17
18impl ResponseBody for StreamPreviewImageResponse {
19    fn deserialize(
20        bytes: Vec<u8>,
21    ) -> Result<Self, Box<crate::endpoints::ExecuteEndpointRequestError>> {
22        Ok(Self(bytes))
23    }
24}
25
26impl Endpoint for GetStreamPreviewImage {
27    type Response = StreamPreviewImageResponse;
28
29    fn into_request(self) -> crate::request::Request {
30        Request::builder()
31            .method(Method::POST)
32            .path(format!("/streams/{}/preview", self.stream_key))
33            .build()
34    }
35}