mirror of
https://github.com/fluencelabs/marine.git
synced 2024-12-12 14:55:32 +00:00
introduce NodeWasmService trait
This commit is contained in:
parent
06de91968e
commit
9da7cc0957
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -517,8 +517,8 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ipfs_node"
|
||||
version = "0.1.0"
|
||||
name = "ipfs_node_service"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"cmd_lib",
|
||||
"fce",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "ipfs_node"
|
||||
version = "0.1.0"
|
||||
name = "ipfs_node_service"
|
||||
version = "0.2.0"
|
||||
authors = ["Fluence Labs"]
|
||||
edition = "2018"
|
||||
|
||||
|
@ -13,10 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#![feature(pattern)]
|
||||
|
||||
mod node;
|
||||
mod node_wasm_service;
|
||||
|
||||
pub use fce::IValue;
|
||||
|
||||
pub use node::*;
|
||||
pub use node::IpfsNode;
|
||||
pub use node::NodeError;
|
||||
pub use node::NodePublicInterface;
|
||||
pub use node::NodeModulePublicInterface;
|
||||
pub use node_wasm_service::NodeWasmService;
|
||||
|
@ -15,9 +15,15 @@
|
||||
*/
|
||||
|
||||
mod node;
|
||||
mod node_wasm_service;
|
||||
|
||||
pub use node::IpfsNode;
|
||||
pub use node::NodeError;
|
||||
pub use node::NodePublicInterface;
|
||||
pub use node::NodeModulePublicInterface;
|
||||
pub use node_wasm_service::NodeWasmService;
|
||||
|
||||
use fce::IValue;
|
||||
use node::IpfsNode;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
@ -46,7 +46,7 @@ impl IpfsNode {
|
||||
for entry in fs::read_dir(core_modules_dir.into())? {
|
||||
let path = entry?.path();
|
||||
if path.is_dir() {
|
||||
// just pass directories
|
||||
// just skip directories
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -74,8 +74,10 @@ impl IpfsNode {
|
||||
rpc_module_config,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
pub fn rpc_call(
|
||||
impl crate::node_wasm_service::NodeWasmService for IpfsNode {
|
||||
fn rpc_call(
|
||||
&mut self,
|
||||
wasm_rpc: &[u8],
|
||||
func_name: &str,
|
||||
@ -92,7 +94,7 @@ impl IpfsNode {
|
||||
Ok(call_result)
|
||||
}
|
||||
|
||||
pub fn get_interface(&self) -> NodePublicInterface {
|
||||
fn get_interface(&self) -> NodePublicInterface {
|
||||
let mut modules = Vec::with_capacity(self.module_names.len());
|
||||
|
||||
for module_name in self.module_names.iter() {
|
@ -17,11 +17,11 @@
|
||||
mod config;
|
||||
mod errors;
|
||||
mod imports;
|
||||
mod node;
|
||||
mod ipfs_node;
|
||||
mod node_public_interface;
|
||||
mod utils;
|
||||
|
||||
pub use node::IpfsNode;
|
||||
pub use ipfs_node::IpfsNode;
|
||||
pub use errors::NodeError;
|
||||
pub use node_public_interface::NodePublicInterface;
|
||||
pub use node_public_interface::NodeModulePublicInterface;
|
||||
|
31
examples/ipfs_node/src/node_wasm_service.rs
Normal file
31
examples/ipfs_node/src/node_wasm_service.rs
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright 2020 Fluence Labs Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
use crate::NodeError;
|
||||
use crate::NodePublicInterface;
|
||||
|
||||
use fce::IValue;
|
||||
|
||||
pub trait NodeWasmService {
|
||||
fn rpc_call(
|
||||
&mut self,
|
||||
wasm_rpc: &[u8],
|
||||
func_name: &str,
|
||||
args: &[IValue],
|
||||
) -> Result<Vec<IValue>, NodeError>;
|
||||
|
||||
fn get_interface(&self) -> NodePublicInterface;
|
||||
}
|
Loading…
Reference in New Issue
Block a user