✨♻️➖➕ bevy_vanth, vanth, vanth_derive, vanth_transport: Many changes in preparation for networking
- Created new crate `bevy_vanth` with basic plugin structure for Bevy integration. - Refactored `Id` generation in `vanth` to use `OsRng` and removed redundant `to_u128_pair`/`from_u128_pair` methods. - Moved networking functionality into new `net` module with `Node`, `Packet`, and `Message` types. - Updated `vanth_derive` to use `proc-macro-crate` for reliable crate path resolution. - Added `rand` dependency to replace custom ID generation logic. - Updated `Cargo.toml`/`Cargo.lock` with new dependencies: `bevy_app`, `nix`, `cfg_aliases`, `proc-macro-crate`. - Modified `README.md` with improved project description. - Added commented clippy check in `flake.nix`. - Added `smol`, `async-process`, and `async-trait` dependencies in root and `vanth` crate. - Integrated `vanth` crate into `bevy_vanth` and added serde dependency. - Reorganized test files into module structure for `cli` and `vanth` crates. - Created new modules `compress` and `ecc` in `vanth`. - Implemented `Node` with async `run` method and `Backend` trait for networking in `vanth`. - Renamed `Memory` backend to `InMemoryStore` in `vanth` store module.
This commit is contained in:
parent
5262a266c0
commit
5afe3b61fb
34 changed files with 1887 additions and 483 deletions
|
@ -9,4 +9,5 @@ proc-macro = true
|
|||
[dependencies]
|
||||
quote.workspace = true
|
||||
syn.workspace = true
|
||||
proc-macro2.workspace = true
|
||||
proc-macro2.workspace = true
|
||||
proc-macro-crate.workspace = true
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
use proc_macro::TokenStream;
|
||||
use proc_macro_crate::{crate_name, FoundCrate};
|
||||
use proc_macro2::Span;
|
||||
use quote::quote;
|
||||
use syn::parse_quote;
|
||||
use syn::{DeriveInput, GenericParam, Generics, parse_macro_input};
|
||||
|
@ -11,6 +13,15 @@ pub fn vanth_derive(input: TokenStream) -> TokenStream {
|
|||
|
||||
let mut generics = input.generics.clone();
|
||||
|
||||
let vanth_path = match crate_name("vanth") {
|
||||
Ok(FoundCrate::Itself) => quote!(crate),
|
||||
Ok(FoundCrate::Name(name)) => {
|
||||
let ident = syn::Ident::new(&name, Span::call_site());
|
||||
quote!(::#ident)
|
||||
}
|
||||
Err(_) => quote!(vanth),
|
||||
};
|
||||
|
||||
let type_params: Vec<syn::Ident> = generics
|
||||
.params
|
||||
.iter()
|
||||
|
@ -25,7 +36,7 @@ pub fn vanth_derive(input: TokenStream) -> TokenStream {
|
|||
|
||||
let mut where_clause = generics.where_clause.clone().unwrap_or_else(|| parse_quote!(where));
|
||||
for tp in &type_params {
|
||||
where_clause.predicates.push(parse_quote!(#tp : vanth::Vanth));
|
||||
where_clause.predicates.push(parse_quote!(#tp : #vanth_path::Vanth));
|
||||
}
|
||||
|
||||
let (impl_generics, ty_generics, _) = generics.split_for_impl();
|
||||
|
@ -34,19 +45,19 @@ pub fn vanth_derive(input: TokenStream) -> TokenStream {
|
|||
quote! { String::new() }
|
||||
} else {
|
||||
quote! {
|
||||
format!("<{}>", [#(#type_params::ty().path.join("::")),*].join(","))
|
||||
format!("<{}>", [#( <#type_params as #vanth_path::Vanth>::ty().path.join("::") ),*].join(","))
|
||||
}
|
||||
};
|
||||
|
||||
let expanded = quote! {
|
||||
impl #impl_generics vanth::Vanth for #name #ty_generics #where_clause {
|
||||
fn ty() -> vanth::Ty {
|
||||
impl #impl_generics #vanth_path::Vanth for #name #ty_generics #where_clause {
|
||||
fn ty() -> #vanth_path::Ty {
|
||||
let module_path = module_path!();
|
||||
let mut path: Vec<String> = module_path.split("::").map(|s| s.to_string()).collect();
|
||||
let base_name = stringify!(#name);
|
||||
let generics_str = #generics_code;
|
||||
path.push(format!("{}{}", base_name, generics_str));
|
||||
vanth::Ty { path }
|
||||
#vanth_path::Ty { path }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue