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§
type LocationType
Required Methods§
sourcefn erase(&mut self) -> Result<(), ResourceError>
fn erase(&mut self) -> Result<(), ResourceError>
erase content resource
sourcefn read(&self) -> Result<String, ResourceError>
fn read(&self) -> Result<String, ResourceError>
read resource content
sourcefn location(&self) -> &Self::LocationType
fn location(&self) -> &Self::LocationType
return embedded location type (e.g. PathBuf for files)
Provided Methods§
sourcefn content(&self) -> Result<String, ResourceError>
fn content(&self) -> Result<String, ResourceError>
return resource content
Object Safety§
This trait is not object safe.