Skip to content

Commit

Permalink
Redacters options reduced clones and simplified API
Browse files Browse the repository at this point in the history
  • Loading branch information
abdolence committed Aug 10, 2024
1 parent 03695de commit 10fb5e3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/commands/copy_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pub async fn command_copy(
let mut destination_fs = DetectFileSystem::open(destination, &app_reporter).await?;

let maybe_redacter = match redacter_options {
Some(ref options) => Some(Redacters::new_redacter(options, &app_reporter).await?),
Some(options) => Some(Redacters::new_redacter(options, &app_reporter).await?),
None => None,
};

Expand Down
48 changes: 12 additions & 36 deletions src/redacters/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,49 +87,25 @@ impl Display for RedacterOptions {

impl<'a> Redacters<'a> {
pub async fn new_redacter(
redacter_options: &RedacterOptions,
redacter_options: RedacterOptions,
reporter: &'a AppReporter<'a>,
) -> AppResult<Self> {
match redacter_options.provider_options {
RedacterProviderOptions::GcpDlp(ref options) => Ok(Redacters::GcpDlp(
GcpDlpRedacter::new(
redacter_options.base_options.clone(),
options.clone(),
reporter,
)
.await?,
RedacterProviderOptions::GcpDlp(options) => Ok(Redacters::GcpDlp(
GcpDlpRedacter::new(redacter_options.base_options, options, reporter).await?,
)),
RedacterProviderOptions::AwsComprehend(ref options) => Ok(Redacters::AwsComprehendDlp(
AwsComprehendRedacter::new(
redacter_options.base_options.clone(),
options.clone(),
reporter,
)
.await?,
RedacterProviderOptions::AwsComprehend(options) => Ok(Redacters::AwsComprehendDlp(
AwsComprehendRedacter::new(redacter_options.base_options, options, reporter)
.await?,
)),
RedacterProviderOptions::MsPresidio(ref options) => Ok(Redacters::MsPresidio(
MsPresidioRedacter::new(
redacter_options.base_options.clone(),
options.clone(),
reporter,
)
.await?,
RedacterProviderOptions::MsPresidio(options) => Ok(Redacters::MsPresidio(
MsPresidioRedacter::new(redacter_options.base_options, options, reporter).await?,
)),
RedacterProviderOptions::GeminiLlm(ref options) => Ok(Redacters::GeminiLlm(
GeminiLlmRedacter::new(
redacter_options.base_options.clone(),
options.clone(),
reporter,
)
.await?,
RedacterProviderOptions::GeminiLlm(options) => Ok(Redacters::GeminiLlm(
GeminiLlmRedacter::new(redacter_options.base_options, options, reporter).await?,
)),
RedacterProviderOptions::OpenAiLlm(ref options) => Ok(Redacters::OpenAiLlm(
OpenAiLlmRedacter::new(
redacter_options.base_options.clone(),
options.clone(),
reporter,
)
.await?,
RedacterProviderOptions::OpenAiLlm(options) => Ok(Redacters::OpenAiLlm(
OpenAiLlmRedacter::new(redacter_options.base_options, options, reporter).await?,
)),
}
}
Expand Down

0 comments on commit 10fb5e3

Please sign in to comment.