pub struct JsonFile<R>where
R: DeserializeOwned,{ /* private fields */ }Expand description
A wrapper around FileWatcher which can be used to read the contents of a JSON file.
Implementations§
Source§impl<R> JsonFile<R>where
R: DeserializeOwned,
impl<R> JsonFile<R>where
R: DeserializeOwned,
Sourcepub fn new<P: AsRef<Path>>(
path: P,
unblocker: impl Into<Arc<dyn Unblocker>>,
) -> Result<JsonFile<R>, LogFSError>
pub fn new<P: AsRef<Path>>( path: P, unblocker: impl Into<Arc<dyn Unblocker>>, ) -> Result<JsonFile<R>, LogFSError>
Creates a new JsonFile from the provided path and unblocker.
Sourcepub fn byte_content(&self) -> Result<Vec<u8>, LogFSError>
pub fn byte_content(&self) -> Result<Vec<u8>, LogFSError>
Returns the current contents of the file as a raw byte vector.
Sourcepub fn string_content(&self) -> Result<String, LogFSError>
pub fn string_content(&self) -> Result<String, LogFSError>
Returns the current contents of the file as a string.
Sourcepub fn content(&self) -> Result<Option<R>, LogFSError>
pub fn content(&self) -> Result<Option<R>, LogFSError>
Returns the current contents of the file as a deserialized object, or None if the file is empty (which happens when the game clears the file before it starts to write.)
pub async fn byte_content_async(&self) -> Result<Vec<u8>, LogFSError>
Available on crate feature
asynchronous only.pub async fn string_content_async(&self) -> Result<String, LogFSError>
Available on crate feature
asynchronous only.pub async fn content_async(&self) -> Result<Option<R>, LogFSError>
Available on crate feature
asynchronous only.Auto Trait Implementations§
impl<R> Freeze for JsonFile<R>
impl<R> RefUnwindSafe for JsonFile<R>where
R: RefUnwindSafe,
impl<R> Send for JsonFile<R>where
R: Send,
impl<R> Sync for JsonFile<R>where
R: Sync,
impl<R> Unpin for JsonFile<R>where
R: Unpin,
impl<R> UnsafeUnpin for JsonFile<R>
impl<R> UnwindSafe for JsonFile<R>where
R: UnwindSafe,
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