Skip to content

Commit

Permalink
fix: remove Box from arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
edytapawlak authored and Robert Mitwicki committed Mar 21, 2024
1 parent a19eb29 commit 06bdd2a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
9 changes: 5 additions & 4 deletions oca/src/facade/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use oca_bundle::state::oca::OCABundle;
use oca_bundle::Encode;
use oca_dag::build_core_db_model;

use std::borrow::Borrow;
use std::rc::Rc;

#[derive(thiserror::Error, Debug, serde::Serialize)]
Expand Down Expand Up @@ -63,7 +64,7 @@ impl References for Box<dyn DataStorage> {

impl Facade {
fn parse_and_check_base(
storage: &Box<dyn DataStorage>,
storage: &dyn DataStorage,
ocafile: String,
) -> Result<(Option<OCABundle>, OCAAst), Vec<ValidationError>> {
let mut errors: Vec<ValidationError> = vec![];
Expand Down Expand Up @@ -149,7 +150,7 @@ impl Facade {

#[cfg(feature = "local-references")]
pub fn validate_ocafile<R: References>(
storage: &Box<dyn DataStorage>,
storage: &dyn DataStorage,
ocafile: String,
references: &mut R,
) -> Result<OCABuild, Vec<ValidationError>> {
Expand All @@ -159,7 +160,7 @@ impl Facade {

#[cfg(not(feature = "local-references"))]
pub fn validate_ocafile(
storage: &Box<dyn DataStorage>,
storage: &dyn DataStorage,
ocafile: String,
) -> Result<OCABuild, Vec<ValidationError>> {
let (base, oca_ast) = Self::parse_and_check_base(storage, ocafile)?;
Expand All @@ -172,7 +173,7 @@ impl Facade {

pub fn build_from_ocafile(&mut self, ocafile: String) -> Result<OCABundle, Vec<Error>> {
let oca_build = Self::validate_ocafile(
&self.db_cache,
self.db_cache.borrow(),
ocafile,
#[cfg(feature = "local-references")]
&mut self.db,
Expand Down
8 changes: 4 additions & 4 deletions oca/src/facade/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use said::SelfAddressingIdentifier;
use serde::Serialize;
#[cfg(feature = "local-references")]
use std::collections::HashMap;
use std::rc::Rc;
use std::{borrow::Borrow, rc::Rc};
use std::str::FromStr;

#[derive(Debug, Serialize)]
Expand Down Expand Up @@ -259,7 +259,7 @@ impl Facade {
said: SelfAddressingIdentifier,
with_dep: bool,
) -> Result<BundleWithDependencies, Vec<String>> {
get_oca_bundle(&self.db_cache, said, with_dep)
get_oca_bundle(self.db_cache.borrow(), said, with_dep)
}

pub fn get_oca_bundle_steps(
Expand Down Expand Up @@ -358,7 +358,7 @@ impl Facade {
}

pub fn get_oca_bundle(
storage: &Box<dyn DataStorage>,
storage: &dyn DataStorage,
said: SelfAddressingIdentifier,
with_dep: bool,
) -> Result<BundleWithDependencies, Vec<String>> {
Expand All @@ -377,7 +377,7 @@ pub fn get_oca_bundle(
let mut dep_bundles = vec![];
if with_dep {
for refs in retrive_all_references(oca_bundle.clone()) {
let dep_bundle = get_oca_bundle(&storage, refs, true)?;
let dep_bundle = get_oca_bundle(storage, refs, true)?;
dep_bundles.push(dep_bundle.bundle);
dep_bundles.extend(dep_bundle.dependencies);
}
Expand Down
5 changes: 3 additions & 2 deletions oca/src/facade/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::data_storage::DataStorage;
use crate::repositories::SQLiteConfig;
use std::borrow::Borrow;
use std::rc::Rc;

pub mod build;
Expand Down Expand Up @@ -40,7 +41,7 @@ impl Facade {
}
}

pub fn storage<'a>(&self) -> &Box<dyn DataStorage> {
&self.db_cache
pub fn storage<'a>(&self) -> &dyn DataStorage {
self.db_cache.borrow()
}
}

0 comments on commit 06bdd2a

Please sign in to comment.