pub trait SourceService {
// Required methods
fn initialize(
&self,
params: SourceInitializeParams,
initialized_repo: InitializedRepo,
) -> Result<InitializedSource, SkootError>;
fn commit_and_push_changes(
&self,
source: InitializedSource,
message: String,
) -> Result<(), SkootError>;
fn write_file<P: AsRef<Path>, C: AsRef<[u8]>>(
&self,
source: InitializedSource,
path: P,
name: String,
contents: C,
) -> Result<(), SkootError>;
fn read_file<P: AsRef<Path>>(
&self,
source: &InitializedSource,
path: P,
name: String,
) -> Result<String, SkootError>;
fn hash_file<P: AsRef<Path>>(
&self,
source: &InitializedSource,
path: P,
name: String,
) -> Result<String, SkootError>;
fn pull_updates(&self, source: InitializedSource) -> Result<(), SkootError>;
}Expand description
The SourceService trait provides an interface for and managing a project’s source code.
This code is usually something a local git repo. The service differs from the repo service
in that it’s focused on the files and not the repo itself.
Required Methods§
Sourcefn initialize(
&self,
params: SourceInitializeParams,
initialized_repo: InitializedRepo,
) -> Result<InitializedSource, SkootError>
fn initialize( &self, params: SourceInitializeParams, initialized_repo: InitializedRepo, ) -> Result<InitializedSource, SkootError>
Initializes a source code directory for a project. This usually involves cloning a repo from a repo service.
§Errors
Returns an error if the source code directory can’t be initialized.
Sourcefn commit_and_push_changes(
&self,
source: InitializedSource,
message: String,
) -> Result<(), SkootError>
fn commit_and_push_changes( &self, source: InitializedSource, message: String, ) -> Result<(), SkootError>
Commits changes to the repo and pushed them to the remote.
§Errors
Returns an error if the changes can’t be committed and pushed to the remote.
Sourcefn write_file<P: AsRef<Path>, C: AsRef<[u8]>>(
&self,
source: InitializedSource,
path: P,
name: String,
contents: C,
) -> Result<(), SkootError>
fn write_file<P: AsRef<Path>, C: AsRef<[u8]>>( &self, source: InitializedSource, path: P, name: String, contents: C, ) -> Result<(), SkootError>
Writes a file to the source code directory.
§Errors
Returns an error if the file can’t be written to the source code directory.
Sourcefn read_file<P: AsRef<Path>>(
&self,
source: &InitializedSource,
path: P,
name: String,
) -> Result<String, SkootError>
fn read_file<P: AsRef<Path>>( &self, source: &InitializedSource, path: P, name: String, ) -> Result<String, SkootError>
Reads a file from the source code directory.
§Errors
Returns an error if the file can’t be read from the source code directory.
Sourcefn hash_file<P: AsRef<Path>>(
&self,
source: &InitializedSource,
path: P,
name: String,
) -> Result<String, SkootError>
fn hash_file<P: AsRef<Path>>( &self, source: &InitializedSource, path: P, name: String, ) -> Result<String, SkootError>
hash_file returns the SHA256 hash of a file.
§Errors
Returns an error if the file can’t be opened and hashed.
Sourcefn pull_updates(&self, source: InitializedSource) -> Result<(), SkootError>
fn pull_updates(&self, source: InitializedSource) -> Result<(), SkootError>
Pulls updates from the remote repo.
§Errors
Returns an error if the updates can’t be pulled from the remote repo.
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.