Skip to content

Commit

Permalink
init edcode-macros lib
Browse files Browse the repository at this point in the history
  • Loading branch information
0123456789-jpg committed Mar 19, 2024
1 parent df3380c commit 03c32a4
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
26 changes: 26 additions & 0 deletions crates/util/edcode-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "rimecraft-edcode-macros"
version = "0.1.0"
edition = "2021"
authors = ["C191239 <[email protected]>"]
description = "Derive macros for rimecraft-edcode"
repository = "https://github.com/rimecraft-rs/rimecraft/"
license = "AGPL-3.0-or-later"
categories = ["encoding"]

[badges]
maintenance = { status = "passively-maintained" }

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
syn = { version = "2.0" }

[dev-dependencies]
rimecraft-edcode = { path = "../edcode" }

[lints]
workspace = true

[lib]
proc-macro = true
9 changes: 9 additions & 0 deletions crates/util/edcode-macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//! Proc-macros for deriving [`rimecraft_edcode`] traits.
use proc_macro::TokenStream;

/// Derive [`rimecraft_edcode::Encode`] to types.
#[proc_macro_derive(Encode)]
pub fn derive_encode(_input: TokenStream) -> TokenStream {
TokenStream::new()
}
2 changes: 2 additions & 0 deletions crates/util/edcode/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ maintenance = { status = "passively-maintained" }
[dependencies]
bytes = "1.5"
serde = { version = "1.0", optional = true }
rimecraft-edcode-macros = { path = "../edcode-macros", optional = true }
# custom formats
fastnbt = { version = "2.4", optional = true }
serde_json = { version = "1.0", optional = true }
Expand All @@ -24,6 +25,7 @@ glam = { version = "0.25", optional = true }
[features]
# default = ["serde", "nbt", "json", "uuid", "glam"]
serde = ["dep:serde"]
macros = ["dep:rimecraft-edcode-macros"]
# custom formats
fastnbt = ["serde", "dep:fastnbt"]
json = ["serde", "dep:serde_json"]
Expand Down
3 changes: 3 additions & 0 deletions crates/util/edcode/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ use std::io;

pub use bytes;

#[cfg(feature = "macros")]
pub use rimecraft_edcode_macros::Encode;

/// Describes types that can be encoded into a packet buffer.
pub trait Encode {
/// Encode into a buffer.
Expand Down

0 comments on commit 03c32a4

Please sign in to comment.