fluence_sdk_main/
lib.rs

1/*
2 * Copyright 2018 Fluence Labs Limited
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//! The main part of Fluence backend SDK. Contains `export_allocator`, `logger` and `result`
18//! modules.
19
20#![allow(clippy::missing_safety_doc)]
21#![allow(clippy::needless_doctest_main)]
22#![doc(html_root_url = "https://docs.rs/fluence-sdk-main/0.6.9")]
23#![deny(
24    dead_code,
25    nonstandard_style,
26    unused_imports,
27    unused_mut,
28    unused_variables,
29    unused_unsafe,
30    unreachable_patterns
31)]
32#![warn(rust_2018_idioms)]
33
34mod export_allocator;
35#[cfg(any(feature = "debug", feature = "logger"))]
36mod logger;
37mod module_manifest;
38mod result;
39mod sdk_version_embedder;
40
41pub use export_allocator::allocate;
42
43#[cfg(feature = "logger")]
44pub use logger::WasmLoggerBuilder;
45#[cfg(feature = "logger")]
46pub use logger::TargetMap;
47#[cfg(feature = "logger")]
48pub use logger::WASM_LOG_ENV_NAME;
49
50pub use result::get_result_ptr;
51pub use result::get_result_size;
52pub use result::set_result_ptr;
53pub use result::set_result_size;
54pub use result::release_objects;
55pub use result::add_object_to_release;
56
57pub use module_manifest::MANIFEST_SECTION_NAME;
58pub use sdk_version_embedder::VERSION_SECTION_NAME;
59
60// these logs will be printed only if debug feature is enabled
61#[macro_export]
62macro_rules! debug_log {
63    ($msg_generator:expr) => {
64        #[cfg(feature = "debug")]
65        {
66            let level = log::Level::Info as i32;
67            let target = 0i32;
68            let msg = $msg_generator;
69            crate::logger::log_utf8_string(level, target, msg.as_ptr() as i32, msg.len() as i32);
70        }
71    };
72}