mirror of
https://github.com/fluencelabs/examples
synced 2025-04-25 10:42:16 +00:00
separate lib code from demo code
This commit is contained in:
parent
033cdfc203
commit
f668c13074
5
aqua-examples/ceramic-demo/services/ceramic-adapter-basic/.gitignore
vendored
Normal file
5
aqua-examples/ceramic-demo/services/ceramic-adapter-basic/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
debug/
|
||||||
|
target/
|
||||||
|
Cargo.lock
|
||||||
|
**/*.bk
|
||||||
|
**/*.bak
|
@ -0,0 +1,22 @@
|
|||||||
|
[package]
|
||||||
|
name = "ceramic"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["boneyard93501 <4523011+boneyard93501@users.noreply.github.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
description = "ceramic-adapter"
|
||||||
|
license = "Apache-2.0"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "ceramic_adapter"
|
||||||
|
path = "src/main.rs"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
marine-rs-sdk = { version = "0.6.11", features = ["logger"] }
|
||||||
|
log = "0.4.14"
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
marine-rs-sdk-test = "0.1.11"
|
||||||
|
|
||||||
|
[dev]
|
||||||
|
[profile.release]
|
||||||
|
opt-level = "s"
|
@ -0,0 +1,59 @@
|
|||||||
|
use marine_rs_sdk::{marine, MountedBinaryResult};
|
||||||
|
|
||||||
|
#[marine]
|
||||||
|
// general purpose request call where users provides the vector of
|
||||||
|
// properly formatted args
|
||||||
|
// e.g.,
|
||||||
|
pub fn ceramic_request(args: Vec<String>) -> MountedBinaryResult {
|
||||||
|
ceramic(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[marine]
|
||||||
|
pub fn create_stream(payload: String) -> MountedBinaryResult {
|
||||||
|
let args = vec![
|
||||||
|
"create".to_string(),
|
||||||
|
"tile".to_string(),
|
||||||
|
"--content".to_string(),
|
||||||
|
payload,
|
||||||
|
];
|
||||||
|
ceramic(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[marine]
|
||||||
|
pub fn show(stream_id: String) -> MountedBinaryResult {
|
||||||
|
ceramic(vec!["show".to_string(), stream_id])
|
||||||
|
}
|
||||||
|
|
||||||
|
#[marine]
|
||||||
|
pub fn state(stream_id: String) -> MountedBinaryResult {
|
||||||
|
ceramic(vec!["state".to_string(), stream_id])
|
||||||
|
}
|
||||||
|
|
||||||
|
#[marine]
|
||||||
|
pub fn update(stream_id: String, payload: String) -> MountedBinaryResult {
|
||||||
|
ceramic(vec![
|
||||||
|
"update".to_string(),
|
||||||
|
stream_id,
|
||||||
|
"--content".to_string(),
|
||||||
|
payload,
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
#[marine]
|
||||||
|
pub fn create_schema(schema: String) -> MountedBinaryResult {
|
||||||
|
let args = vec![
|
||||||
|
"create".to_string(),
|
||||||
|
"tile".to_string(),
|
||||||
|
"--content".to_string(),
|
||||||
|
schema,
|
||||||
|
];
|
||||||
|
ceramic(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
// link to binary on host node with `extern` where the path comes from the
|
||||||
|
// config file. E.g., `/usr/bin/ceramic`
|
||||||
|
#[marine]
|
||||||
|
#[link(wasm_import_module = "host")]
|
||||||
|
extern "C" {
|
||||||
|
pub fn ceramic(cmd: Vec<String>) -> MountedBinaryResult;
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2021 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 marine_rs_sdk::{module_manifest, WasmLoggerBuilder};
|
||||||
|
|
||||||
|
module_manifest!();
|
||||||
|
|
||||||
|
pub mod ceramic_cli;
|
||||||
|
|
||||||
|
pub fn main() {
|
||||||
|
WasmLoggerBuilder::new().build().ok();
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user