Trait Resource

Source
pub trait Resource: FromStr {
    type LocationType;

    // Required methods
    fn write(&mut self, content: &str) -> Result<(), ResourceError>;
    fn erase(&mut self) -> Result<(), ResourceError>;
    fn append(&mut self, content: &str) -> Result<(), ResourceError>;
    fn read(&self) -> Result<String, ResourceError>;
    fn name(&self) -> &String;
    fn location(&self) -> &Self::LocationType;

    // Provided method
    fn content(&self) -> Result<String, ResourceError> { ... }
}
Expand description

General physical or virtual resource

Required Associated Types§

Required Methods§

Source

fn write(&mut self, content: &str) -> Result<(), ResourceError>

write resource content

Source

fn erase(&mut self) -> Result<(), ResourceError>

erase content resource

Source

fn append(&mut self, content: &str) -> Result<(), ResourceError>

append resource content

Source

fn read(&self) -> Result<String, ResourceError>

read resource content

Source

fn name(&self) -> &String

return resource name

Source

fn location(&self) -> &Self::LocationType

return embedded location type (e.g. PathBuf for files)

Provided Methods§

Source

fn content(&self) -> Result<String, ResourceError>

return resource content

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.

Implementors§