feat: Added/expanded Typed impls
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use lua_typed::Typed;
|
||||
use tokio::sync::RwLock;
|
||||
use tokio::task::JoinHandle;
|
||||
use tracing::debug;
|
||||
@@ -74,3 +75,44 @@ impl mlua::UserData for Timeout {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl Typed for Timeout {
|
||||
fn type_name() -> String {
|
||||
"Timeout".into()
|
||||
}
|
||||
|
||||
fn generate_header() -> Option<String> {
|
||||
let type_name = Self::type_name();
|
||||
Some(format!("---@class {type_name}\nlocal {type_name}\n"))
|
||||
}
|
||||
|
||||
fn generate_members() -> Option<String> {
|
||||
let mut output = String::new();
|
||||
|
||||
let type_name = Self::type_name();
|
||||
|
||||
output += &format!(
|
||||
"---@async\n---@param timeout number\n---@param callback {}\nfunction {type_name}:start(timeout, callback) end\n",
|
||||
ActionCallback::<()>::type_name()
|
||||
);
|
||||
|
||||
output += &format!("---@async\nfunction {type_name}:cancel() end\n",);
|
||||
|
||||
output +=
|
||||
&format!("---@async\n---@return boolean\nfunction {type_name}:is_waiting() end\n",);
|
||||
|
||||
Some(output)
|
||||
}
|
||||
|
||||
fn generate_footer() -> Option<String> {
|
||||
let mut output = String::new();
|
||||
|
||||
let type_name = Self::type_name();
|
||||
|
||||
output += &format!("utils.{type_name} = {{}}\n");
|
||||
output += &format!("---@return {type_name}\n");
|
||||
output += &format!("function utils.{type_name}.new() end\n");
|
||||
|
||||
Some(output)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user