Skip to content

Commit 1756fb7

Browse files
committed
refactor(proto): move protocols to separate crates
1 parent 684709f commit 1756fb7

File tree

17 files changed

+612
-508
lines changed

17 files changed

+612
-508
lines changed

Cargo.lock

Lines changed: 31 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace]
22
resolver = "2"
3-
members = [ "crawlspace-macro","crawlspace", "crawlspace-slime"]
3+
members = [ "crawlspace-macro","crawlspace" , "crawlspace-proto", "crawlspace-proto-1_8"]
44

55
[profile.release-stripped]
66
inherits = "release"

crawlspace-macro/src/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Copyright (c) 2024 Andrew Brower.
3+
* This file is part of Crawlspace.
4+
*
5+
* Crawlspace is free software: you can redistribute it and/or
6+
* modify it under the terms of the GNU Affero General Public
7+
* License as published by the Free Software Foundation, either
8+
* version 3 of the License, or (at your option) any later version.
9+
*
10+
* Crawlspace is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public
16+
* License along with Crawlspace. If not, see
17+
* <https://www.gnu.org/licenses/>.
18+
*/
19+
120
use proc_macro::{Span, TokenStream};
221
use quote::quote;
322
use syn::{parse_macro_input, parse_quote, DeriveInput, Fields, Ident, Index, Lit, Path};

crawlspace-proto-1_8/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "crawlspace-proto-1_8"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]
7+
bytes = "1.10.1"
8+
crawlspace-proto = { path = "../crawlspace-proto" }

crawlspace-proto-1_8/src/lib.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2024 Andrew Brower.
3+
* This file is part of Crawlspace.
4+
*
5+
* Crawlspace is free software: you can redistribute it and/or
6+
* modify it under the terms of the GNU Affero General Public
7+
* License as published by the Free Software Foundation, either
8+
* version 3 of the License, or (at your option) any later version.
9+
*
10+
* Crawlspace is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
* Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public
16+
* License along with Crawlspace. If not, see
17+
* <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
use bytes::BytesMut;
21+
use crawlspace_proto::{
22+
Packet, Read, ServerboundPacket,
23+
datatypes::{VarInt, VariableNumber},
24+
};
25+
26+
/// Minecraft versions 1.8-1.8.9
27+
/// Protocol version 47
28+
pub struct Protocol47<R, W> {
29+
reader: R,
30+
writer: W,
31+
bytebuf: BytesMut,
32+
}
33+
34+
impl<R: std::io::Read, W: std::io::Write> Protocol47<R, W> {
35+
pub fn new(reader: R, writer: W) -> Self {
36+
Self {
37+
reader,
38+
writer,
39+
bytebuf: BytesMut::new(),
40+
}
41+
}
42+
43+
fn read_packet(&mut self) -> Result<Box<dyn ServerboundPacket>, crawlspace_proto::ErrorKind> {
44+
let len = VarInt::read(&mut self.reader)?;
45+
46+
todo!();
47+
}
48+
}
49+
50+
impl<R: std::io::Read, W: std::io::Write> crawlspace_proto::Protocol for Protocol47<R, W> {
51+
fn handshake_player(&mut self) {}
52+
}

crawlspace-proto/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "crawlspace-proto"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]
7+
bitfield-struct = "0.11.0"
8+
byteorder = "1.5.0"
9+
serde = { version = "1.0.219", features = ["derive"] }
10+
thiserror = "2.0.16"
11+
uuid = "1.18.0"

0 commit comments

Comments
 (0)