Trait nmd_core::resource::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

Object Safety§

This trait is not object safe.

Implementors§