Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rust module API rework #1660

Merged
merged 13 commits into from
Sep 27, 2024
Next Next commit
Rust module API rework
  • Loading branch information
coolreader18 committed Sep 26, 2024
commit 1ccc8e6c03a348823e43014e5cfaca45de8c3a3b
527 changes: 139 additions & 388 deletions crates/bindings-macro/src/lib.rs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions crates/bindings-macro/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::{check_duplicate, sym};
pub(crate) struct SatsType<'a> {
pub ident: &'a syn::Ident,
pub generics: &'a syn::Generics,
pub name: String,
pub name: LitStr,
pub krate: TokenStream,
// may want to use in the future
#[allow(unused)]
Expand Down Expand Up @@ -104,14 +104,14 @@ pub(crate) fn extract_sats_type<'a>(
check_duplicate(&name, &meta)?;
let value = meta.value()?;
let v = value.parse::<LitStr>()?;
name = Some(v.value());
name = Some(v);
}
});
Ok(())
})?;
}
let krate = krate.unwrap_or(crate_fallback);
let name = name.unwrap_or_else(|| ident.to_string());
let name = name.unwrap_or_else(|| LitStr::new(&ident.to_string(), ident.span()));

Ok(SatsType {
ident,
Expand Down
2 changes: 2 additions & 0 deletions crates/bindings-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,8 @@ pub struct Errno(NonZeroU16);
// once Error gets exposed from core this crate can be no_std again
impl std::error::Error for Errno {}

pub type Result<T, E = Errno> = core::result::Result<T, E>;

macro_rules! def_errno {
($($err_name:ident($errno:literal, $errmsg:literal),)*) => {
impl Errno {
Expand Down
39 changes: 0 additions & 39 deletions crates/bindings/src/impls.rs

This file was deleted.

Loading