Call it library not module

This commit is contained in:
lumi 2025-06-25 20:13:09 +10:00
parent a81271c0a8
commit 530a1530ba
Signed by: luaneko
GPG Key ID: 406809B8763FF07A
4 changed files with 26 additions and 12 deletions

View File

@ -1,15 +1,15 @@
//! The `lb:fs` module provides utilities for interacting with the file system asynchronously. //! The `lb:fs` library provides utilities for interacting with the file system asynchronously.
//! //!
//! # Exports //! # Exports
//! //!
//! See [`lb_libfs`] for items exported by this module. //! See [`lb_libfs`] for items exported by this library.
use luaffi::{cdef, metatype}; use luaffi::{cdef, metatype};
use std::io; use std::io;
use tokio::fs; use tokio::fs;
/// Items exported by the `lb:fs` module. /// Items exported by the `lb:fs` library.
/// ///
/// This module can be obtained by calling `require` in Lua. /// This library can be obtained by calling `require` in Lua.
/// ///
/// ```lua /// ```lua
/// local fs = require("lb:fs"); /// local fs = require("lb:fs");

View File

@ -1,9 +1,9 @@
//! The `lb:net` module provides an asynchronous network API for creating TCP or UDP servers and //! The `lb:net` library provides an asynchronous network API for creating TCP or UDP servers and
//! clients. //! clients.
//! //!
//! # Exports //! # Exports
//! //!
//! See [`lb_libnet`] for items exported by this module. //! See [`lb_libnet`] for items exported by this library.
use derive_more::{From, FromStr}; use derive_more::{From, FromStr};
use luaffi::{cdef, metatype}; use luaffi::{cdef, metatype};
use std::{ use std::{
@ -12,9 +12,9 @@ use std::{
}; };
use tokio::net::{TcpListener, TcpSocket, TcpStream}; use tokio::net::{TcpListener, TcpSocket, TcpStream};
/// Items exported by the `lb:net` module. /// Items exported by the `lb:net` library.
/// ///
/// This module can be obtained by calling `require` in Lua. /// This library can be obtained by calling `require` in Lua.
/// ///
/// ```lua /// ```lua
/// local net = require("lb:net"); /// local net = require("lb:net");

View File

@ -41,6 +41,7 @@ impl Builder {
let mut s = State::new()?; let mut s = State::new()?;
let mut chunk = Chunk::new(self.registry.done()); let mut chunk = Chunk::new(self.registry.done());
chunk.extend(include_bytes!("./runtime.lua")); chunk.extend(include_bytes!("./runtime.lua"));
// println!("{chunk}");
s.eval(chunk.path("[luby]"), 0, 0)?; s.eval(chunk.path("[luby]"), 0, 0)?;
s s
}, },

View File

@ -1,6 +1,19 @@
local ffi = require("ffi") local fs = require("lb:fs")
local lb = ffi.new("struct lb_core")
print(lb) -- do
-- local start = os.clock()
-- for i = 1, 50000 do
-- fs:read("crates/luaffi_impl/src/metatype.rs")
-- end
-- local finish = os.clock()
-- print("finish in " .. (finish - start))
-- end
lb.spawn("") do
local start = os.clock()
for i = 1, 30000 do
fs:read_sync("bacon.toml")
end
local finish = os.clock()
print("finish in " .. (finish - start))
end