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