pub struct FileHandle<U: Ui> { /* private fields */ }Expand description
A handle to a File widget
This handle acts much like an RwData<File>, but it also
includes an Area that can be acted upon alongside the
File.
This is the only way you are supposed to read information about
the File, in order to display it on Widgets, create
Texts, and do all sorts of things. You can, of course, also
modify a File from within this struct, but you should be
careful to prevent infinite loops, where you modify a File, it
gets updated, and then you modify it again after noticing that it
has changed.
The main difference between a FileHandle<U> and a
Handle<File<U>, U> is that the Handle is capable of acting
on selections, but is fixed to just one File, while the
FileHandle can automatically point to the current File.
Implementations§
Source§impl<U: Ui> FileHandle<U>
impl<U: Ui> FileHandle<U>
Sourcepub fn read<Ret>(
&self,
pa: &Pass,
f: impl FnOnce(&File<U>, &U::Area) -> Ret,
) -> Ret
pub fn read<Ret>( &self, pa: &Pass, f: impl FnOnce(&File<U>, &U::Area) -> Ret, ) -> Ret
Reads from the File and the Area using a Pass
The consistent use of a Pass for the purposes of
reading/writing to the values of RwDatas ensures that no
panic or invalid borrow happens at runtime, even while working
with untrusted code. More importantly, Duat uses these
guarantees in order to give the end user a ridiculous amount
of freedom in where they can do things, whilst keeping Rust’s
number one rule and ensuring thread safety, even with a
relatively large amount of shareable state.
§Panics
Panics if there is a mutable borrow of this struct somewhere,
which could happen if you use RwData::write_unsafe or
RwData::write_unsafe_as from some other place
Sourcepub fn write<Ret>(
&self,
pa: &mut Pass,
f: impl FnOnce(&mut File<U>, &U::Area) -> Ret,
) -> Ret
pub fn write<Ret>( &self, pa: &mut Pass, f: impl FnOnce(&mut File<U>, &U::Area) -> Ret, ) -> Ret
Writes to the File and Area within using a Pass
The consistent use of a Pass for the purposes of
reading/writing to the values of RwDatas ensures that no
panic or invalid borrow happens at runtime, even while working
with untrusted code. More importantly, Duat uses these
guarantees in order to give the end user a ridiculous amount
of freedom in where they can do things, whilst keeping Rust’s
number one rule and ensuring thread safety, even with a
relatively large amount of shareable state.
§Panics
Panics if there is any type of borrow of this struct
somewhere, which could happen if you use
RwData::read_unsafe or RwData::write_unsafe, for
example.
Sourcepub fn has_changed(&self) -> bool
pub fn has_changed(&self) -> bool
Wether someone else called write or write_as since the
last read or write
Do note that this DOES NOT mean that the value inside has
actually been changed, it just means a mutable reference was
acquired after the last call to has_changed.
Some types like Text, and traits like Widget offer
needs_update methods, you should try to determine what
parts to look for changes.
Generally though, you can use this method to gauge that.
Sourcepub fn has_swapped(&self) -> bool
pub fn has_swapped(&self) -> bool
Wether the File within has swapped to another
This can only happen when this is a
Trait Implementations§
Source§impl<U: Clone + Ui> Clone for FileHandle<U>
impl<U: Clone + Ui> Clone for FileHandle<U>
Source§fn clone(&self) -> FileHandle<U>
fn clone(&self) -> FileHandle<U>
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
source. Read more