dust_devil_core/sandstorm/
shutdown.rs

1use std::io::Error;
2
3use tokio::io::{AsyncRead, AsyncWrite};
4
5use crate::serialize::{ByteRead, ByteWrite};
6
7use super::SandstormCommandType;
8
9/// A Sandstorm shutdown request.
10pub struct ShutdownRequest;
11
12/// A Sandstorm shutdown response.
13pub struct ShutdownResponse;
14
15impl ByteRead for ShutdownRequest {
16    async fn read<R: AsyncRead + Unpin + ?Sized>(_reader: &mut R) -> Result<Self, Error> {
17        Ok(Self)
18    }
19}
20
21impl ByteWrite for ShutdownRequest {
22    async fn write<W: AsyncWrite + Unpin + ?Sized>(&self, writer: &mut W) -> Result<(), Error> {
23        SandstormCommandType::Shutdown.write(writer).await
24    }
25}
26
27impl ByteRead for ShutdownResponse {
28    async fn read<R: AsyncRead + Unpin + ?Sized>(_reader: &mut R) -> Result<Self, Error> {
29        Ok(Self)
30    }
31}
32
33impl ByteWrite for ShutdownResponse {
34    async fn write<W: AsyncWrite + Unpin + ?Sized>(&self, writer: &mut W) -> Result<(), Error> {
35        SandstormCommandType::Shutdown.write(writer).await
36    }
37}