From b1572cc9f191253d10da9d9c7d773139f0c380f9 Mon Sep 17 00:00:00 2001 From: luaneko Date: Thu, 26 Jun 2025 23:24:48 +1000 Subject: [PATCH] Rename lsdir to read_dir and dirent to dir_entry --- crates/lb/src/fs.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/crates/lb/src/fs.rs b/crates/lb/src/fs.rs index 227a3a9..1c3bc99 100644 --- a/crates/lb/src/fs.rs +++ b/crates/lb/src/fs.rs @@ -63,11 +63,11 @@ impl lb_fslib { Ok(std::fs::write(path, contents)?) } - pub async extern "Lua-C" fn lsdir(&self, path: &str) -> Result { + pub async extern "Lua-C" fn read_dir(&self, path: &str) -> Result { Ok(tokio::fs::read_dir(path).await?.into()) } - pub extern "Lua-C" fn lsdir_sync(&self, path: &str) -> Result { + pub extern "Lua-C" fn read_dir_sync(&self, path: &str) -> Result { Ok(std::fs::read_dir(path)?.into()) } } @@ -75,25 +75,25 @@ impl lb_fslib { /// Iterator over the entries in a directory. #[derive(Debug, From)] #[cdef] -pub struct lb_lsdir(#[opaque] tokio::fs::ReadDir); +pub struct lb_read_dir(#[opaque] tokio::fs::ReadDir); #[metatype] -impl lb_lsdir { +impl lb_read_dir { #[call] - pub async extern "Lua-C" fn next(&mut self) -> Result> { + pub async extern "Lua-C" fn next(&mut self) -> Result> { Ok(self.0.next_entry().await?.map(Into::into)) } } -/// Synchronous version of [`lb_lsdir`]. +/// Synchronous version of [`lb_read_dir`]. #[derive(Debug, From)] #[cdef] -pub struct lb_lsdir_sync(#[opaque] std::fs::ReadDir); +pub struct lb_read_dir_sync(#[opaque] std::fs::ReadDir); #[metatype] -impl lb_lsdir_sync { +impl lb_read_dir_sync { #[call] - pub extern "Lua-C" fn next(&mut self) -> Result> { + pub extern "Lua-C" fn next(&mut self) -> Result> { Ok(self.0.next().transpose()?.map(Into::into)) } } @@ -101,10 +101,10 @@ impl lb_lsdir_sync { /// Entry inside of a directory on the filesystem. #[derive(Debug, From)] #[cdef] -pub struct lb_dirent(#[opaque] tokio::fs::DirEntry); +pub struct lb_dir_entry(#[opaque] tokio::fs::DirEntry); #[metatype] -impl lb_dirent { +impl lb_dir_entry { pub extern "Lua-C" fn path(&self) -> String { self.0.path().to_string_lossy().into() } @@ -132,13 +132,13 @@ impl lb_dirent { } } -/// Synchronous version of [`lb_dirent`]. +/// Synchronous version of [`lb_dir_entry`]. #[derive(Debug, From)] #[cdef] -pub struct lb_dirent_sync(#[opaque] std::fs::DirEntry); +pub struct lb_dir_entry_sync(#[opaque] std::fs::DirEntry); #[metatype] -impl lb_dirent_sync { +impl lb_dir_entry_sync { pub extern "Lua-C" fn path(&self) -> String { self.0.path().to_string_lossy().into() } @@ -167,7 +167,7 @@ impl lb_dirent_sync { } } -/// Structure representing a type of file with accessors for each file type. +/// Structure representing the type of a file with accessors for each file type. #[derive(Debug, From)] #[cdef] pub struct lb_file_type(#[opaque] std::fs::FileType);