#[repr(C)]pub struct File {
pub ptr: Box<Arc<Mutex<File>>>,
pub path: AzString,
pub run_destructor: bool,
}Expand description
Thread-safe file handle with path tracking for the C API.
Fields§
§ptr: Box<Arc<Mutex<File>>>§path: AzString§run_destructor: boolImplementations§
Source§impl File
impl File
Sourcepub fn open(path: &str) -> Option<Self>
pub fn open(path: &str) -> Option<Self>
Opens a file in read-only mode, returning None on failure.
Sourcepub fn create(path: &str) -> Option<Self>
pub fn create(path: &str) -> Option<Self>
Creates a file (truncating if it exists), returning None on failure.
Sourcepub fn read_to_string(&mut self) -> Option<AzString>
pub fn read_to_string(&mut self) -> Option<AzString>
Reads the file at self.path into a string.
Sourcepub fn read_to_bytes(&mut self) -> Option<U8Vec>
pub fn read_to_bytes(&mut self) -> Option<U8Vec>
Reads the file at self.path into a byte vector.
Sourcepub fn write_string(&mut self, string: &str) -> Option<()>
pub fn write_string(&mut self, string: &str) -> Option<()>
Writes a string to the file handle.
Sourcepub fn write_bytes(&mut self, bytes: &[u8]) -> Option<()>
pub fn write_bytes(&mut self, bytes: &[u8]) -> Option<()>
Writes bytes to the file handle and syncs to disk.
Trait Implementations§
Source§impl PartialOrd for File
impl PartialOrd for File
impl Eq for File
Auto Trait Implementations§
impl Freeze for File
impl RefUnwindSafe for File
impl Send for File
impl Sync for File
impl Unpin for File
impl UnsafeUnpin for File
impl UnwindSafe for File
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more