logos.std.io.fs

Module std · package logos-std

Types

structDirEntry

struct DirEntry

One directory entry, as yielded by read_dir and walk_dir.

Fields

is_dir: bool

True iff the entry is a directory (read_dir: d_type-based, symlink/unknown reads as false; walk_dir: stat-based, follows symlinks).

name: String

Entry name: bare child name from read_dir, full path from walk_dir.

structFile

struct File

Open file handle paired with its own IoRing; all I/O is issued through io_uring.

Fields

fd: i32
ring: IoRing

Methods

fn close(self: &mut File) -> i32

Closes the file descriptor and marks the handle closed; idempotent. Returns 0 on success (or if already closed), a negative errno on failure.

fn is_open(self: &File) -> bool

Returns true if the handle holds a valid file descriptor (not yet closed).

fn read_at(self: &mut File, buf: *mut u8, len: i64, offset: i64) -> i32

Reads up to len bytes at absolute offset into buf. Returns bytes read (0 = EOF) or a negative errno on failure.

fn write_at(self: &mut File, buf: *const u8, len: i64, offset: i64) -> i32

Writes len bytes from buf at absolute offset. Returns bytes written (may be short) or a negative errno on failure.

structReadDir

struct ReadDir

Non-recursive directory iterator: yields the children of a path, skipping "." and "..". Obtain via read_dir; the OS handle is closed on exhaustion or drop.

Implements: Iterator Drop

Fields

done: bool
handle: *mut u8

Methods

fn all(self: ReadDir, pred: AllFn) -> bool
fn any(self: ReadDir, pred: AnyFn) -> bool
fn chain(self: ReadDir, other: ChainOther) -> ChainIter<ReadDir, ChainOther, DirEntry>
fn collect(self: ReadDir) -> C
fn count(self: ReadDir) -> i64
fn drop(self: ReadDir) -> void
fn enumerate(self: ReadDir) -> EnumIter<ReadDir, DirEntry>
fn filter(self: ReadDir, pred: fn(DirEntry) -> bool) -> FilterIter<ReadDir, DirEntry>
fn find(self: &mut ReadDir, pred: FindFn) -> Option
fn find_map(self: ReadDir, f: FindMapFn) -> Option
fn fold(self: ReadDir, init: Acc, f: FoldFn) -> Acc
fn for_each(self: ReadDir, f: EachFn) -> void
fn inspect(self: ReadDir, visit: fn(DirEntry) -> void, zero: DirEntry) -> InspectIter<ReadDir, DirEntry>
fn last(self: ReadDir) -> Option
fn map(self: ReadDir, f: MapFn) -> MapIter<ReadDir, DirEntry, MapOut, MapFn>
fn max_by(self: ReadDir, cmp: fn(DirEntry, DirEntry) -> i32) -> Option
fn min_by(self: ReadDir, cmp: fn(DirEntry, DirEntry) -> i32) -> Option
fn next(self: &mut ReadDir) -> Option
fn nth(self: &mut ReadDir, n: i64) -> Option
fn peekable(self: ReadDir) -> PeekableIter<ReadDir, DirEntry>
fn position(self: &mut ReadDir, pred: PosFn) -> Option
fn product(self: ReadDir) -> S
fn reduce(self: ReadDir, f: ReduceFn) -> Option
fn skip(self: ReadDir, n: i64) -> SkipIter<ReadDir, DirEntry>
fn skip_while(self: ReadDir, pred: fn(DirEntry) -> bool, zero: DirEntry) -> SkipWhileIter<ReadDir, DirEntry>
fn step_by(self: ReadDir, step: i64, zero: DirEntry) -> StepByIter<ReadDir, DirEntry>
fn sum(self: ReadDir) -> S
fn take(self: ReadDir, n: i64) -> TakeIter<ReadDir, DirEntry>
fn take_while(self: ReadDir, pred: fn(DirEntry) -> bool, zero: DirEntry) -> TakeWhileIter<ReadDir, DirEntry>
fn try_fold(self: ReadDir, init: Acc, f: TryFoldFn) -> ControlFlow
fn try_for_each(self: ReadDir, f: TryEachFn) -> ControlFlow
fn zip(self: ReadDir, other: ZipOther) -> ZipIter<ReadDir, ZipOther, DirEntry, ZipOtherItem>

Functions

fncanonical

fn canonical(path: *const u8) -> Result

Resolves symlinks and returns an absolute, normalized path (wraps libc realpath). Returns Err(-errno) on failure.

fncreate

fn create(path: *const u8) -> Result

Creates or truncates NUL-terminated path (O_RDWR|O_CREAT|O_TRUNC, mode 0666).

fnexists

fn exists(path: &[u8]) -> bool

Returns true iff path exists; safe str form (errors read as false).

fnexists_checked

fn exists_checked(path: *const u8) -> Result

Returns Ok(true)/Ok(false) for exists/not-exists, Err(-errno) for I/O errors.

fnfile_size

fn file_size(path: *const u8) -> Result

Returns the file size in bytes, or Err(-errno).

fnis_dir

fn is_dir(path: &[u8]) -> bool

Returns true iff path is a directory; safe str form (errors read as false).

fnis_file

fn is_file(path: &[u8]) -> bool

Returns true iff path is a regular file; safe str form (errors read as false).

fnmkdir

fn mkdir(path: *const u8, mode: i32) -> Result

Creates directory path with permissions mode; Err(-errno) on failure, EEXIST included.

fnmkdir_p

fn mkdir_p(path: &[u8]) -> Result

Creates path and each missing directory along it with mode 0o755 (mkdir -p). Existing directories are not an error; a non-directory non-leaf component yields Err(-ENOTDIR).

fnmtime_ns

fn mtime_ns(path: &[u8]) -> Result

Returns the modification time in nanoseconds since epoch, or Err(-errno); safe str form.

fnopen

fn open(path: *const u8) -> Result

Opens NUL-terminated path read-only (O_RDONLY); Err carries a negative errno.

fnopen_append

fn open_append(path: *const u8) -> Result

Opens NUL-terminated path for append (O_WRONLY|O_CREAT|O_APPEND, mode 0666).

fnparent

fn parent(path: &[u8]) -> &[u8]

Returns the directory part of path: everything before the last '/'. Borrowed slice into path (no copy); "" if path has no '/'.

fnread_dir

fn read_dir(path: *const u8) -> Result

Opens directory path for non-recursive iteration. Returns Err(-1) on any open failure (errno is not propagated by opendir).

fnread_to_string

fn read_to_string(path: &[u8]) -> Result

Reads the entire file into a String; safe str overload that null-terminates path.

fnrm_rf

fn rm_rf(path: &[u8]) -> Result

Removes path and everything under it (rm -rf semantics); returns the first error hit. A non-existent path is not an error. The directory check follows symlinks, so a symlink to a directory is traversed and the target’s contents are removed.

fnrmdir

fn rmdir(path: *const u8) -> Result

Removes the empty directory path, or returns Err(-errno).

fnwalk_dir

fn walk_dir(path: &[u8]) -> Vec<DirEntry>

Returns the eager pre-order list of all entries rooted at path. The first entry is path itself; each entry’s name holds the full path, directly usable in FS ops. Skips "."/"..". Directory checks are stat-based, so symlinks to directories are traversed.

fnwrite_string

fn write_string(path: &[u8], s: &String) -> Result

Overwrites the file with s; safe str overload that null-terminates path.