Struct fswatch::FswSession
[−]
[src]
pub struct FswSession { /* fields omitted */ }
A session in fswatch, revolving around a handle.
Calling new
creates a new handle, initiating a new session. Options can be set
before calling start_monitor
.
Methods
impl FswSession
[src]
fn new(monitor_type: FswMonitorType) -> Result<FswSession, FswError>
Create a new session and handle, using the given monitor type.
fn default() -> Result<FswSession, FswError>
Create a new session and handle, using the system default monitor type.
This is a convenience method for FswSession::new(FswMonitorType::SystemDefaultMonitorType)
.
fn builder() -> FswSessionBuilder
Create a new empty FswSessionBuilder
.
This is a convenience method for
FswSessionBuilder::empty()
.
fn builder_paths<P>(paths: Vec<P>) -> FswSessionBuilder where
P: AsRef<Path>,
P: AsRef<Path>,
Create a new FswSessionBuilder
with the given paths.
This is a convenience method for
FswSessionBuilder::new(paths)
.
fn add_path<T: AsRef<Path>>(&self, path: T) -> Result<(), FswError>
Add a path to watch for this session.
fn add_property(&self, name: &str, value: &str) -> Result<(), FswError>
Add a custom property to this session.
fn set_allow_overflow(&self, allow_overflow: bool) -> Result<(), FswError>
Set whether to allow overflow for this session.
fn set_callback<F>(&self, callback: F) -> Result<(), FswError> where
F: Fn(Vec<FswEvent>) + 'static,
F: Fn(Vec<FswEvent>) + 'static,
Set the callback for this session.
The callback will receive a Vec<FswEvent>
, which is a copy of the events given by fswatch.
Safety
Calling this multiple times will cause this session to use the last callback specified, but due to the limited functions in the C API, the previous callbacks will never be freed from memory, causing a memory leak.
fn set_latency(&self, latency: c_double) -> Result<(), FswError>
Set the latency for this session.
fn set_recursive(&self, recursive: bool) -> Result<(), FswError>
Set whether this session should be recursive.
fn set_directory_only(&self, directory_only: bool) -> Result<(), FswError>
Set whether this session should be directory only.
fn set_follow_symlinks(&self, follow_symlinks: bool) -> Result<(), FswError>
Set whether this session should follow symlinks.
fn add_event_type_filter(
&self,
event_type: FswEventFlag
) -> Result<(), FswError>
&self,
event_type: FswEventFlag
) -> Result<(), FswError>
Add an event filter for the given event flag.
fn add_filter(&self, filter: FswMonitorFilter) -> Result<(), FswError>
Add a filter.
fn start_monitor(&self) -> Result<(), FswError>
Start monitoring for this session.
Depending on the monitor you are using, this method may block.
Errors
This method will return an error if set_callback
has not been
successfully called or if add_path
has not been successfully called at
least once. To start the monitor without these checks, use
start_monitor_unchecked
.
unsafe fn start_monitor_unchecked(&self) -> Result<(), FswError>
Start monitoring for this session.
Depending on the monitor you are using, this method may block.
Safety
This function will cause an illegal memory access or another type of memory error, crashing the program, if it is called without a callback or without any paths. As far as I can tell, this is a problem in the C API of libfswatch.
fn destroy_session(&self) -> Result<(), FswError>
Destroy this session, freeing it from memory and invalidating its handle.
This is called automatically when the session goes out of scope.
Trait Implementations
impl IntoIterator for FswSession
[src]
type Item = FswEvent
The type of the elements being iterated over.
type IntoIter = FswSessionIterator
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more