Skip to main content

JsonFile

Struct JsonFile 

Source
pub struct JsonFile<R>{ /* 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>

Source

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.

Source

pub fn byte_content(&self) -> Result<Vec<u8>, LogFSError>

Returns the current contents of the file as a raw byte vector.

Source

pub fn string_content(&self) -> Result<String, LogFSError>

Returns the current contents of the file as a string.

Source

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.)

Source

pub async fn byte_content_async(&self) -> Result<Vec<u8>, LogFSError>

Available on crate feature asynchronous only.
Source

pub async fn string_content_async(&self) -> Result<String, LogFSError>

Available on crate feature asynchronous only.
Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.