Update docs
This commit is contained in:
@@ -1,79 +0,0 @@
|
||||
//! # Channel library
|
||||
//!
|
||||
//! The `lb:chan` library provides primitives for asynchronous communication between tasks via
|
||||
//! message passing channels.
|
||||
//!
|
||||
//! ## Exports
|
||||
//!
|
||||
//! See [`lb_chanlib`] for items exported by this library.
|
||||
use luaffi::{cdef, metatype};
|
||||
|
||||
/// Items exported by the `lb:chan` library.
|
||||
///
|
||||
/// This library can be acquired by calling
|
||||
/// [`require("lb:chan")`](https://www.lua.org/manual/5.1/manual.html#pdf-require).
|
||||
///
|
||||
/// ```lua
|
||||
/// local chan = require("lb:chan");
|
||||
/// ```
|
||||
#[cdef(module = "lb:chan")]
|
||||
pub struct lb_chanlib;
|
||||
|
||||
#[metatype]
|
||||
impl lb_chanlib {
|
||||
#[new]
|
||||
extern "Lua-C" fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
|
||||
extern "Lua" fn unbounded(self) {
|
||||
let (send, recv) = (__new(__ct.lb_sender), __new(__ct.lb_receiver));
|
||||
self.__unbounded(send, recv);
|
||||
(send, recv)
|
||||
}
|
||||
|
||||
extern "Lua" fn bounded(self, cap: u32) {
|
||||
assert(cap >= 0, "channel capacity must be nonnegative");
|
||||
let (send, recv) = (__new(__ct.lb_sender), __new(__ct.lb_receiver));
|
||||
self.__bounded(cap, send, recv);
|
||||
(send, recv)
|
||||
}
|
||||
|
||||
// extern "Lua-C" fn __unbounded(&self, s: *mut lb_sender, r: *mut lb_receiver) {
|
||||
// let (send, recv) = flume::unbounded();
|
||||
// unsafe {
|
||||
// ptr::write(s, lb_sender { send });
|
||||
// ptr::write(r, lb_receiver { recv });
|
||||
// }
|
||||
// }
|
||||
|
||||
// extern "Lua-C" fn __bounded(&self, cap: usize, s: *mut lb_sender, r: *mut lb_receiver) {
|
||||
// let (send, recv) = flume::bounded(cap);
|
||||
// unsafe {
|
||||
// ptr::write(s, lb_sender { send });
|
||||
// ptr::write(r, lb_receiver { recv });
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
// #[cdef]
|
||||
// pub struct lb_sender {
|
||||
// #[opaque]
|
||||
// send: Sender<c_int>,
|
||||
// }
|
||||
|
||||
// #[metatype]
|
||||
// impl lb_sender {
|
||||
// extern "Lua" fn send(self, value: _) {
|
||||
// let key = __ref(value);
|
||||
// }
|
||||
// }
|
||||
|
||||
// #[cdef]
|
||||
// pub struct lb_receiver {
|
||||
// #[opaque]
|
||||
// recv: Receiver<c_int>,
|
||||
// }
|
||||
|
||||
// #[metatype]
|
||||
// impl lb_receiver {}
|
||||
@@ -1,4 +1,4 @@
|
||||
//! # Filesystem library
|
||||
//! Filesystem library.
|
||||
//!
|
||||
//! The `lb:fs` library provides synchronous and asynchronous utilities for interacting with the
|
||||
//! filesystem.
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//! luby standard library
|
||||
#[cfg(feature = "task")]
|
||||
pub mod chan;
|
||||
//! luby core libraries.
|
||||
#[cfg(feature = "fs")]
|
||||
pub mod fs;
|
||||
#[cfg(feature = "net")]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! # Networking library
|
||||
//! Network library.
|
||||
//!
|
||||
//! The `lb:net` library provides an asynchronous network API for creating TCP or UDP servers and
|
||||
//! clients.
|
||||
//! The `lb:net` library provides an asynchronous network API for woring with TCP, UDP and IPC
|
||||
//! sockets.
|
||||
//!
|
||||
//! ## Exports
|
||||
//!
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! # Task library
|
||||
//! Task library.
|
||||
//!
|
||||
//! The `lb:task` library primitives for asynchronous communication between tasks via message
|
||||
//! passing channels.
|
||||
//! The `lb:task` library provides utilities for the scheduling of and communication between
|
||||
//! asynchronous tasks.
|
||||
//!
|
||||
//! ## Exports
|
||||
//!
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
//! Time library.
|
||||
//!
|
||||
//! The `lb:time` library provides utilities for working with the date and time and its related
|
||||
//! constructs.
|
||||
//!
|
||||
//! ## Exports
|
||||
//!
|
||||
//! See [`lb_timelib`] for items exported by this library.
|
||||
use luaffi::{cdef, metatype};
|
||||
|
||||
/// Items exported by the `lb:time` library.
|
||||
///
|
||||
/// This library can be acquired by calling
|
||||
/// [`require("lb:time")`](https://www.lua.org/manual/5.1/manual.html#pdf-require).
|
||||
///
|
||||
/// ```lua
|
||||
/// local time = require("lb:time");
|
||||
/// ```
|
||||
#[cdef(module = "lb:time")]
|
||||
pub struct lb_timelib;
|
||||
|
||||
@@ -10,11 +26,13 @@ impl lb_timelib {
|
||||
Self
|
||||
}
|
||||
|
||||
/// Returns an instant object that represents the current time at the time of calling.
|
||||
pub extern "Lua-C" fn instant() -> lb_instant {
|
||||
lb_instant::new(std::time::Instant::now())
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents the measurement of a monotonically nondecreasing clock.
|
||||
#[cdef]
|
||||
pub struct lb_instant(#[opaque] std::time::Instant);
|
||||
|
||||
@@ -24,7 +42,8 @@ impl lb_instant {
|
||||
Self(instant)
|
||||
}
|
||||
|
||||
pub extern "Lua-C" fn elapsed(&self) -> f64 {
|
||||
/// Returns the number of seconds elapsed since this instant was measured.
|
||||
pub extern "Lua-C" fn elapsed_secs(&self) -> f64 {
|
||||
self.0.elapsed().as_secs_f64()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user