Let modules decide their own name via #[cdef] macro
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// use flume::{Receiver, Sender};
|
||||
use luaffi::{cdef, metatype};
|
||||
|
||||
#[cdef]
|
||||
#[cdef(module = "lb:chan")]
|
||||
pub struct lb_chanlib;
|
||||
|
||||
#[metatype]
|
||||
|
||||
@@ -15,7 +15,7 @@ use tokio::fs;
|
||||
/// ```lua
|
||||
/// local fs = require("lb:fs");
|
||||
/// ```
|
||||
#[cdef]
|
||||
#[cdef(module = "lb:fs")]
|
||||
pub struct lb_fslib;
|
||||
|
||||
#[metatype]
|
||||
|
||||
@@ -37,7 +37,7 @@ type Result<T> = std::result::Result<T, Error>;
|
||||
/// ```lua
|
||||
/// local net = require("lb:net");
|
||||
/// ```
|
||||
#[cdef]
|
||||
#[cdef(module = "lb:net")]
|
||||
pub struct lb_netlib;
|
||||
|
||||
#[metatype]
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use derive_more::{Deref, DerefMut};
|
||||
use luaffi::{Registry, Type};
|
||||
use luaffi::{Module, Registry};
|
||||
use luajit::{Chunk, State};
|
||||
use std::fmt::Display;
|
||||
use tokio::{
|
||||
task::{JoinHandle, LocalSet, futures::TaskLocalFuture, spawn_local},
|
||||
task_local,
|
||||
@@ -23,8 +22,8 @@ impl Builder {
|
||||
&self.registry
|
||||
}
|
||||
|
||||
pub fn module<T: Type>(&mut self, name: impl Display) -> &mut Self {
|
||||
self.registry.preload::<T>(name);
|
||||
pub fn module<T: Module>(&mut self) -> &mut Self {
|
||||
self.registry.preload::<T>();
|
||||
self
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use luaffi::{cdef, metatype};
|
||||
use std::{ffi::c_int, process};
|
||||
use tokio::task::JoinHandle;
|
||||
|
||||
#[cdef]
|
||||
#[cdef(module = "lb:task")]
|
||||
pub struct lb_tasklib;
|
||||
|
||||
#[metatype]
|
||||
|
||||
Reference in New Issue
Block a user