pub trait SerdeAPI:
Serialize
+ for<'a> Deserialize<'a>
+ Init {
const ACCEPTED_BYTE_FORMATS: &'static [&'static str] = _;
const ACCEPTED_STR_FORMATS: &'static [&'static str] = _;
const RESOURCES_SUBDIR: &'static str = "";
const RESOURCES_DIR: &'static Dir<'_> = _;
Show 16 methods
// Provided methods
fn from_resource<P: AsRef<Path>>(
filepath: P,
skip_init: bool,
) -> Result<Self, Error> { ... }
fn list_resources() -> Result<Vec<PathBuf>, Error> { ... }
fn to_file<P: AsRef<Path>>(&self, filepath: P) -> Result<()> { ... }
fn from_file<P: AsRef<Path>>(
filepath: P,
skip_init: bool,
) -> Result<Self, Error> { ... }
fn to_writer<W: Write>(&self, wtr: W, format: &str) -> Result<()> { ... }
fn to_str(&self, format: &str) -> Result<String> { ... }
fn from_str<S: AsRef<str>>(
contents: S,
format: &str,
skip_init: bool,
) -> Result<Self> { ... }
fn from_reader<R: Read>(
rdr: &mut R,
format: &str,
skip_init: bool,
) -> Result<Self, Error> { ... }
fn to_json(&self) -> Result<String> { ... }
fn from_json<S: AsRef<str>>(json_str: S, skip_init: bool) -> Result<Self> { ... }
fn to_msg_pack(&self) -> Result<Vec<u8>> { ... }
fn from_msg_pack(msg_pack: &[u8], skip_init: bool) -> Result<Self> { ... }
fn to_toml(&self) -> Result<String> { ... }
fn from_toml<S: AsRef<str>>(toml_str: S, skip_init: bool) -> Result<Self> { ... }
fn to_yaml(&self) -> Result<String> { ... }
fn from_yaml<S: AsRef<str>>(yaml_str: S, skip_init: bool) -> Result<Self> { ... }
}Provided Associated Constants§
const ACCEPTED_BYTE_FORMATS: &'static [&'static str] = _
const ACCEPTED_STR_FORMATS: &'static [&'static str] = _
const RESOURCES_SUBDIR: &'static str = ""
const RESOURCES_DIR: &'static Dir<'_> = _
Provided Methods§
Sourcefn from_resource<P: AsRef<Path>>(
filepath: P,
skip_init: bool,
) -> Result<Self, Error>
fn from_resource<P: AsRef<Path>>( filepath: P, skip_init: bool, ) -> Result<Self, Error>
Read (deserialize) an object from a resource file packaged with the altrios-core crate
§Arguments:
filepath- Filepath, relative to the top of theresourcesfolder (excluding any relevant prefix), from which to read the object
Sourcefn list_resources() -> Result<Vec<PathBuf>, Error>
fn list_resources() -> Result<Vec<PathBuf>, Error>
List the available resources in the resources directory
RETURNS: a vector of strings for resources that can be loaded
Sourcefn to_file<P: AsRef<Path>>(&self, filepath: P) -> Result<()>
fn to_file<P: AsRef<Path>>(&self, filepath: P) -> Result<()>
Write (serialize) an object to a file.
Supported file extensions are listed in ACCEPTED_BYTE_FORMATS.
Creates a new file if it does not already exist, otherwise truncates the existing file.
§Arguments
filepath- The filepath at which to write the object
Sourcefn from_file<P: AsRef<Path>>(
filepath: P,
skip_init: bool,
) -> Result<Self, Error>
fn from_file<P: AsRef<Path>>( filepath: P, skip_init: bool, ) -> Result<Self, Error>
Read (deserialize) an object from a file.
Supported file extensions are listed in ACCEPTED_BYTE_FORMATS.
§Arguments:
filepath: The filepath from which to read the object
Sourcefn to_writer<W: Write>(&self, wtr: W, format: &str) -> Result<()>
fn to_writer<W: Write>(&self, wtr: W, format: &str) -> Result<()>
Write (serialize) an object into anything that implements std::io::Write
§Arguments:
wtr- The writer into which to write object dataformat- The target format, any of those listed inACCEPTED_BYTE_FORMATS
Sourcefn to_str(&self, format: &str) -> Result<String>
fn to_str(&self, format: &str) -> Result<String>
Write (serialize) an object into a string
§Arguments:
format- The target format, any of those listed inACCEPTED_STR_FORMATS
Sourcefn from_str<S: AsRef<str>>(
contents: S,
format: &str,
skip_init: bool,
) -> Result<Self>
fn from_str<S: AsRef<str>>( contents: S, format: &str, skip_init: bool, ) -> Result<Self>
Read (deserialize) an object from a string
§Arguments:
contents- The string containing the object dataformat- The source format, any of those listed inACCEPTED_STR_FORMATS
Sourcefn from_reader<R: Read>(
rdr: &mut R,
format: &str,
skip_init: bool,
) -> Result<Self, Error>
fn from_reader<R: Read>( rdr: &mut R, format: &str, skip_init: bool, ) -> Result<Self, Error>
Deserialize an object from anything that implements std::io::Read
§Arguments:
rdr- The reader from which to read object dataformat- The source format, any of those listed inACCEPTED_BYTE_FORMATS
Sourcefn from_json<S: AsRef<str>>(json_str: S, skip_init: bool) -> Result<Self>
fn from_json<S: AsRef<str>>(json_str: S, skip_init: bool) -> Result<Self>
Read (deserialize) an object from a JSON string
§Arguments
json_str- JSON-formatted string to deserialize from
Sourcefn to_msg_pack(&self) -> Result<Vec<u8>>
fn to_msg_pack(&self) -> Result<Vec<u8>>
Write (serialize) an object to a message pack
Sourcefn from_msg_pack(msg_pack: &[u8], skip_init: bool) -> Result<Self>
fn from_msg_pack(msg_pack: &[u8], skip_init: bool) -> Result<Self>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.