Compare commits

..

No commits in common. "16af1c1bd0bdd4e8d5fbe85fd36df23c681b0f8e" and "19e11489891b988fdb15e5b2af183d9cbd8a1647" have entirely different histories.

3 changed files with 9 additions and 26 deletions

9
Cargo.lock generated
View file

@ -49,9 +49,9 @@ dependencies = [
[[package]]
name = "bytes"
version = "1.7.1"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50"
checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952"
[[package]]
name = "cc"
@ -160,9 +160,9 @@ dependencies = [
[[package]]
name = "indexmap"
version = "2.3.0"
version = "2.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0"
checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26"
dependencies = [
"equivalent",
"hashbrown",
@ -414,7 +414,6 @@ name = "tokio-gemini"
version = "0.1.0"
dependencies = [
"base64ct",
"bytes",
"mime",
"num_enum",
"sha2",

View file

@ -11,7 +11,6 @@ categories = ["network-programming"]
[dependencies]
base64ct = "1.6.0"
bytes = "1.7.1"
mime = "0.3.17"
num_enum = "0.7.3"
sha2 = "0.10.8"

View file

@ -1,23 +1,20 @@
use crate::{status::Status, LibError};
use bytes::Bytes;
use tokio::io::AsyncReadExt;
type BodyStream = tokio_rustls::client::TlsStream<tokio::net::TcpStream>;
#[derive(Debug)]
pub struct Response {
status: Status,
message: String,
stream: BodyStream,
body: BodyStream,
}
impl Response {
pub fn new(status: Status, message: String, stream: BodyStream) -> Self {
pub fn new(status: Status, message: String, body: BodyStream) -> Self {
Response {
status,
message,
stream,
body,
}
}
@ -33,19 +30,7 @@ impl Response {
self.message.parse().map_err(|e| LibError::InvalidMime(e))
}
pub fn stream(self: &mut Self) -> &mut BodyStream {
&mut self.stream
}
pub async fn bytes(self: &mut Self) -> Result<Bytes, LibError> {
let mut buf = Vec::new();
self.stream.read_to_end(&mut buf).await?;
Ok(Bytes::from(buf))
}
pub async fn text(self: &mut Self) -> Result<String, LibError> {
let mut buf = String::new();
self.stream.read_to_string(&mut buf).await?;
Ok(buf)
pub fn body(self: &mut Self) -> &mut BodyStream {
&mut self.body
}
}