forked from eclipse-kuksa/kuksa-incubation
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sebastian Schildt <sebastian.schildt@de.bosch.com>
- Loading branch information
1 parent
89f9943
commit 0610a79
Showing
3 changed files
with
93 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License 2.0 which is available at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
|
||
|
||
pub mod filestorage; | ||
|
||
pub use filestorage::FileStorage; | ||
use tinyjson::JsonValue; | ||
|
||
trait Storage { | ||
// Associated function signature; `Self` refers to the implementor type. | ||
fn new(config: &JsonValue) -> Self; | ||
|
||
// Method signatures; these will return a string. | ||
fn get(&self, vsspath: &'static str) -> &'static str; | ||
|
||
fn set(&self, vsspath: &'static str, vssvalue: &'static str) -> Result<(), ()>; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License 2.0 which is available at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
|
||
use tinyjson::JsonValue; | ||
|
||
pub struct FileStorage { | ||
storagefile: String, | ||
} | ||
|
||
impl FileStorage { | ||
pub fn new(config: &JsonValue) -> Self { | ||
match config["path"].get::<String>() | ||
{ | ||
Some(x) => { | ||
println!("File Storage path: {}", x); | ||
//FileStorage { storagefile: "Lol" } | ||
let path = x.clone(); | ||
FileStorage { storagefile: path} | ||
} | ||
_ => { | ||
eprintln!("Error: file storage path is invalid"); | ||
std::process::exit(1); | ||
} | ||
} | ||
} | ||
|
||
fn get(&self, vsspath: &'static str) -> &'static str { | ||
println!("Try getting VSS signal {}", vsspath); | ||
&"LOL" | ||
} | ||
|
||
fn set(&self, vsspath: &'static str, vssvalue: &'static str) -> Result<(), ()> { | ||
println!("Setting VSS signal {} to {}", vsspath, vssvalue); | ||
Ok(()) | ||
} | ||
} |