run: |
# Note that the version tags aren't checked into git
touch src/version.rs
- RUSTFLAGS="--cfg=c_bindings" cargo check
+ RUSTFLAGS="--cfg=c_bindings" cargo check --features std
- name: Install cbindgen
run: cargo install --force cbindgen
- name: Checkout Rust-Lightning git
writeln!(w, "\tpub result: *mut {},", ok_type).unwrap();
} else {
writeln!(w, "\t/// Note that this value is always NULL, as there are no contents in the OK variant").unwrap();
- writeln!(w, "\tpub result: *mut std::ffi::c_void,").unwrap();
+ writeln!(w, "\tpub result: *mut core::ffi::c_void,").unwrap();
}
if err_type != "()" {
writeln!(w, "\t/// A pointer to the contents in the error state.").unwrap();
writeln!(w, "\tpub err: *mut {},", err_type).unwrap();
} else {
writeln!(w, "\t/// Note that this value is always NULL, as there are no contents in the Err variant").unwrap();
- writeln!(w, "\tpub err: *mut std::ffi::c_void,").unwrap();
+ writeln!(w, "\tpub err: *mut core::ffi::c_void,").unwrap();
}
writeln!(w, "}}").unwrap();
writeln!(w, "#[repr(C)]").unwrap();
if ok_type != "()" {
writeln!(w, "\t\t\tresult: Box::into_raw(Box::new(o)),").unwrap();
} else {
- writeln!(w, "\t\t\tresult: std::ptr::null_mut(),").unwrap();
+ writeln!(w, "\t\t\tresult: core::ptr::null_mut(),").unwrap();
}
writeln!(w, "\t\t}},").unwrap();
writeln!(w, "\t\tresult_ok: true,").unwrap();
if err_type != "()" {
writeln!(w, "\t\t\terr: Box::into_raw(Box::new(e)),").unwrap();
} else {
- writeln!(w, "\t\t\terr: std::ptr::null_mut(),").unwrap();
+ writeln!(w, "\t\t\terr: core::ptr::null_mut(),").unwrap();
}
writeln!(w, "\t\t}},").unwrap();
writeln!(w, "\t\tresult_ok: false,").unwrap();
writeln!(w, "\t\tlet contents = if o.result_ok {{").unwrap();
if ok_type != "()" {
writeln!(w, "\t\t\tlet result = unsafe {{ o.contents.result }};").unwrap();
- writeln!(w, "\t\t\tunsafe {{ o.contents.result = std::ptr::null_mut() }};").unwrap();
+ writeln!(w, "\t\t\tunsafe {{ o.contents.result = core::ptr::null_mut() }};").unwrap();
writeln!(w, "\t\t\t{}Ptr {{ result }}", mangled_container).unwrap();
} else {
writeln!(w, "\t\t\tlet _ = unsafe {{ Box::from_raw(o.contents.result) }};").unwrap();
- writeln!(w, "\t\t\to.contents.result = std::ptr::null_mut();").unwrap();
- writeln!(w, "\t\t\t{}Ptr {{ result: std::ptr::null_mut() }}", mangled_container).unwrap();
+ writeln!(w, "\t\t\to.contents.result = core::ptr::null_mut();").unwrap();
+ writeln!(w, "\t\t\t{}Ptr {{ result: core::ptr::null_mut() }}", mangled_container).unwrap();
}
writeln!(w, "\t\t}} else {{").unwrap();
if err_type != "()" {
writeln!(w, "\t\t\tlet err = unsafe {{ o.contents.err }};").unwrap();
- writeln!(w, "\t\t\tunsafe {{ o.contents.err = std::ptr::null_mut(); }}").unwrap();
+ writeln!(w, "\t\t\tunsafe {{ o.contents.err = core::ptr::null_mut(); }}").unwrap();
writeln!(w, "\t\t\t{}Ptr {{ err }}", mangled_container).unwrap();
} else {
writeln!(w, "\t\t\tlet _ = unsafe {{ Box::from_raw(o.contents.err) }};").unwrap();
- writeln!(w, "\t\t\to.contents.err = std::ptr::null_mut();").unwrap();
- writeln!(w, "\t\t\t{}Ptr {{ err: std::ptr::null_mut() }}", mangled_container).unwrap();
+ writeln!(w, "\t\t\to.contents.err = core::ptr::null_mut();").unwrap();
+ writeln!(w, "\t\t\t{}Ptr {{ err: core::ptr::null_mut() }}", mangled_container).unwrap();
}
writeln!(w, "\t\t}};").unwrap();
writeln!(w, "\t\tSelf {{").unwrap();
if ok_type != "()" {
writeln!(w, "\t\t\t\tresult: Box::into_raw(Box::new(<{}>::clone(unsafe {{ &*self.contents.result }})))", ok_type).unwrap();
} else {
- writeln!(w, "\t\t\t\tresult: std::ptr::null_mut()").unwrap();
+ writeln!(w, "\t\t\t\tresult: core::ptr::null_mut()").unwrap();
}
writeln!(w, "\t\t\t}} }}").unwrap();
writeln!(w, "\t\t}} else {{").unwrap();
if err_type != "()" {
writeln!(w, "\t\t\t\terr: Box::into_raw(Box::new(<{}>::clone(unsafe {{ &*self.contents.err }})))", err_type).unwrap();
} else {
- writeln!(w, "\t\t\t\terr: std::ptr::null_mut()").unwrap();
+ writeln!(w, "\t\t\t\terr: core::ptr::null_mut()").unwrap();
}
writeln!(w, "\t\t\t}} }}").unwrap();
writeln!(w, "\t\t}}").unwrap();
writeln!(w, "impl {} {{", mangled_container).unwrap();
writeln!(w, "\t#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<{}> {{", inner_type).unwrap();
writeln!(w, "\t\tif self.datalen == 0 {{ return Vec::new(); }}").unwrap();
- writeln!(w, "\t\tlet ret = unsafe {{ Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }}.into();").unwrap();
- writeln!(w, "\t\tself.data = std::ptr::null_mut();").unwrap();
+ writeln!(w, "\t\tlet ret = unsafe {{ Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }}.into();").unwrap();
+ writeln!(w, "\t\tself.data = core::ptr::null_mut();").unwrap();
writeln!(w, "\t\tself.datalen = 0;").unwrap();
writeln!(w, "\t\tret").unwrap();
writeln!(w, "\t}}").unwrap();
writeln!(w, "\t#[allow(unused)] pub(crate) fn as_slice(&self) -> &[{}] {{", inner_type).unwrap();
- writeln!(w, "\t\tunsafe {{ std::slice::from_raw_parts_mut(self.data, self.datalen) }}").unwrap();
+ writeln!(w, "\t\tunsafe {{ core::slice::from_raw_parts_mut(self.data, self.datalen) }}").unwrap();
writeln!(w, "\t}}").unwrap();
writeln!(w, "}}").unwrap();
writeln!(w, "impl Drop for {} {{", mangled_container).unwrap();
writeln!(w, "\tfn drop(&mut self) {{").unwrap();
writeln!(w, "\t\tif self.datalen == 0 {{ return; }}").unwrap();
- writeln!(w, "\t\tunsafe {{ Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }};").unwrap();
+ writeln!(w, "\t\tunsafe {{ Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }};").unwrap();
writeln!(w, "\t}}").unwrap();
writeln!(w, "}}").unwrap();
if clonable {
writeln!(w, "\tfn clone(&self) -> Self {{").unwrap();
writeln!(w, "\t\tlet mut res = Vec::new();").unwrap();
writeln!(w, "\t\tif self.datalen == 0 {{ return Self::from(res); }}").unwrap();
- writeln!(w, "\t\tres.extend_from_slice(unsafe {{ std::slice::from_raw_parts_mut(self.data, self.datalen) }});").unwrap();
+ writeln!(w, "\t\tres.extend_from_slice(unsafe {{ core::slice::from_raw_parts_mut(self.data, self.datalen) }});").unwrap();
writeln!(w, "\t\tSelf::from(res)").unwrap();
writeln!(w, "\t}}").unwrap();
writeln!(w, "}}").unwrap();
use types::*;
use blocks::*;
-const DEFAULT_IMPORTS: &'static str = "\nuse std::str::FromStr;\nuse std::ffi::c_void;\nuse core::convert::Infallible;\nuse bitcoin::hashes::Hash;\nuse crate::c_types::*;\n";
+const DEFAULT_IMPORTS: &'static str = "
+use alloc::str::FromStr;
+use core::ffi::c_void;
+use core::convert::Infallible;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+#[cfg(feature=\"no-std\")]
+use alloc::{vec::Vec, boxed::Box};
+";
// *************************************
// *** Manually-expanded conversions ***
match trait_path {
"lightning::util::ser::Writeable" => {
writeln!(w, "impl {} for {} {{", trait_path, for_obj).unwrap();
- writeln!(w, "\tfn write<W: lightning::util::ser::Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {{").unwrap();
+ writeln!(w, "\tfn write<W: lightning::util::ser::Writer>(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> {{").unwrap();
writeln!(w, "\t\tlet vec = (self.write)(self.this_arg);").unwrap();
writeln!(w, "\t\tw.write_all(vec.as_slice())").unwrap();
writeln!(w, "\t}}\n}}").unwrap();
// Implement supertraits for the C-mapped struct.
walk_supertraits!(t, Some(&types), (
("std::cmp::Eq", _)|("core::cmp::Eq", _) => {
- writeln!(w, "impl std::cmp::Eq for {} {{}}", trait_name).unwrap();
- writeln!(w, "impl std::cmp::PartialEq for {} {{", trait_name).unwrap();
+ writeln!(w, "impl core::cmp::Eq for {} {{}}", trait_name).unwrap();
+ writeln!(w, "impl core::cmp::PartialEq for {} {{", trait_name).unwrap();
writeln!(w, "\tfn eq(&self, o: &Self) -> bool {{ (self.eq)(self.this_arg, o) }}\n}}").unwrap();
},
("std::hash::Hash", _)|("core::hash::Hash", _) => {
- writeln!(w, "impl std::hash::Hash for {} {{", trait_name).unwrap();
- writeln!(w, "\tfn hash<H: std::hash::Hasher>(&self, hasher: &mut H) {{ hasher.write_u64((self.hash)(self.this_arg)) }}\n}}").unwrap();
+ writeln!(w, "impl core::hash::Hash for {} {{", trait_name).unwrap();
+ writeln!(w, "\tfn hash<H: core::hash::Hasher>(&self, hasher: &mut H) {{ hasher.write_u64((self.hash)(self.this_arg)) }}\n}}").unwrap();
},
("Send", _) => {}, ("Sync", _) => {},
("Clone", _) => {
writeln!(w, "}}\n").unwrap();
writeln!(w, "// We're essentially a pointer already, or at least a set of pointers, so allow us to be used").unwrap();
writeln!(w, "// directly as a Deref trait in higher-level structs:").unwrap();
- writeln!(w, "impl std::ops::Deref for {} {{\n\ttype Target = Self;", trait_name).unwrap();
+ writeln!(w, "impl core::ops::Deref for {} {{\n\ttype Target = Self;", trait_name).unwrap();
writeln!(w, "\tfn deref(&self) -> &Self {{\n\t\tself\n\t}}\n}}").unwrap();
}
writeln!(w, "\tpub(crate) fn take_inner(mut self) -> *mut native{} {{", struct_name).unwrap();
writeln!(w, "\t\tassert!(self.is_owned);").unwrap();
writeln!(w, "\t\tlet ret = ObjOps::untweak_ptr(self.inner);").unwrap();
- writeln!(w, "\t\tself.inner = std::ptr::null_mut();").unwrap();
+ writeln!(w, "\t\tself.inner = core::ptr::null_mut();").unwrap();
writeln!(w, "\t\tret").unwrap();
writeln!(w, "\t}}\n}}").unwrap();
writeln!(w, "\t\tlet mut rust_obj = {} {{ inner: ObjOps::heap_alloc(obj), is_owned: true }};", ident).unwrap();
writeln!(w, "\t\tlet mut ret = {}_as_{}(&rust_obj);", ident, trait_obj.ident).unwrap();
writeln!(w, "\t\t// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn").unwrap();
- writeln!(w, "\t\trust_obj.inner = std::ptr::null_mut();").unwrap();
+ writeln!(w, "\t\trust_obj.inner = core::ptr::null_mut();").unwrap();
writeln!(w, "\t\tret.free = Some({}_free_void);", ident).unwrap();
writeln!(w, "\t\tret").unwrap();
}
let ref_type: syn::Type = syn::parse_quote!(&#path);
assert!(!types.write_to_c_conversion_new_var(w, &format_ident!("a"), &*i.self_ty, Some(&gen_types), false), "We don't support new var conversions when comparing equality");
- writeln!(w, "\t// Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core").unwrap();
+ writeln!(w, "\t// Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core").unwrap();
writeln!(w, "\t#[allow(deprecated)]").unwrap();
writeln!(w, "\tlet mut hasher = core::hash::SipHasher::new();").unwrap();
- write!(w, "\tstd::hash::Hash::hash(").unwrap();
+ write!(w, "\tcore::hash::Hash::hash(").unwrap();
types.write_from_c_conversion_prefix(w, &ref_type, Some(&gen_types));
write!(w, "o").unwrap();
types.write_from_c_conversion_suffix(w, &ref_type, Some(&gen_types));
writeln!(w, ", &mut hasher);").unwrap();
- writeln!(w, "\tstd::hash::Hasher::finish(&hasher)\n}}").unwrap();
+ writeln!(w, "\tcore::hash::Hasher::finish(&hasher)\n}}").unwrap();
} else if (path_matches_nongeneric(&trait_path.1, &["core", "clone", "Clone"]) || path_matches_nongeneric(&trait_path.1, &["Clone"])) &&
types.c_type_has_inner_from_path(&resolved_path) {
writeln!(w, "impl Clone for {} {{", ident).unwrap();
writeln!(w, "\tfn clone(&self) -> Self {{").unwrap();
writeln!(w, "\t\tSelf {{").unwrap();
- writeln!(w, "\t\t\tinner: if <*mut native{}>::is_null(self.inner) {{ std::ptr::null_mut() }} else {{", ident).unwrap();
+ writeln!(w, "\t\t\tinner: if <*mut native{}>::is_null(self.inner) {{ core::ptr::null_mut() }} else {{", ident).unwrap();
writeln!(w, "\t\t\t\tObjOps::heap_alloc(unsafe {{ &*ObjOps::untweak_ptr(self.inner) }}.clone()) }},").unwrap();
writeln!(w, "\t\t\tis_owned: true,").unwrap();
writeln!(w, "\t\t}}\n\t}}\n}}").unwrap();
writeln!(out, "#![allow(unused_braces)]").unwrap();
// TODO: We need to map deny(missing_docs) in the source crate(s)
//writeln!(out, "#![deny(missing_docs)]").unwrap();
+
+ writeln!(out, "#![cfg_attr(not(feature = \"std\"), no_std)]").unwrap();
+ writeln!(out, "#[cfg(not(any(feature = \"std\", feature = \"no-std\")))]").unwrap();
+ writeln!(out, "compile_error!(\"at least one of the `std` or `no-std` features must be enabled\");").unwrap();
+ writeln!(out, "extern crate alloc;").unwrap();
+
writeln!(out, "pub mod version;").unwrap();
writeln!(out, "pub mod c_types;").unwrap();
writeln!(out, "pub mod bitcoin;").unwrap();
let mut derived_templates = std::fs::OpenOptions::new().write(true).create(true).truncate(true)
.open(&args[2]).expect("Unable to open new header file");
+ writeln!(&mut derived_templates, "{}", DEFAULT_IMPORTS).unwrap();
let mut header_file = std::fs::OpenOptions::new().write(true).create(true).truncate(true)
.open(&args[3]).expect("Unable to open new header file");
let mut cpp_header_file = std::fs::OpenOptions::new().write(true).create(true).truncate(true)
"core::convert::Infallible" => Some("panic!(\"You must never construct a NotConstructable! : "),
- "std::time::Duration"|"core::time::Duration" => Some("std::time::Duration::from_secs("),
+ "std::time::Duration"|"core::time::Duration" => Some("core::time::Duration::from_secs("),
"std::time::SystemTime" => Some("(::std::time::SystemTime::UNIX_EPOCH + std::time::Duration::from_secs("),
"bech32::u5" => Some(""),
/// TODO: We should never need to use this!
fn real_rust_type_mapping<'equiv>(&self, thing: &'equiv str) -> &'equiv str {
match thing {
- "lightning::io::Read" => "std::io::Read",
+ "lightning::io::Read" => "crate::c_types::io::Read",
_ => thing,
}
}
let is_inner_ref = if let Some(syn::Type::Reference(_)) = single_contained { true } else { false };
if is_ref {
return Some(("if ", vec![
- (".is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner(".to_owned(),
+ (".is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner(".to_owned(),
format!("({}{}.unwrap())", var_access, if is_inner_ref { "" } else { ".as_ref()" }))
], ") }", ContainerPrefixLocation::OutsideConv));
} else {
return Some(("if ", vec![
- (".is_none() { std::ptr::null_mut() } else { ".to_owned(), format!("({}.unwrap())", var_access))
+ (".is_none() { core::ptr::null_mut() } else { ".to_owned(), format!("({}.unwrap())", var_access))
], " }", ContainerPrefixLocation::OutsideConv));
}
} else if self.is_primitive(&inner_path) || self.c_type_from_path(&inner_path, false, false).is_none() {
syn::Type::Path(p) => {
let resolved = self.resolve_path(&p.path, generics);
if self.crate_types.opaques.get(&resolved).is_some() {
- write!(w, "crate::{} {{ inner: std::ptr::null_mut(), is_owned: true }}", resolved).unwrap();
+ write!(w, "crate::{} {{ inner: core::ptr::null_mut(), is_owned: true }}", resolved).unwrap();
} else {
// Assume its a manually-mapped C type, where we can just define an null() fn
write!(w, "{}::null()", self.c_type_from_path(&resolved, false, false).unwrap()).unwrap();
syn::Type::Slice(_) => {
// Option<[]> always implies that we want to treat len() == 0 differently from
// None, so we always map an Option<[]> into a pointer.
- write!(w, " == std::ptr::null_mut()").unwrap();
+ write!(w, " == core::ptr::null_mut()").unwrap();
EmptyValExpectedTy::ReferenceAsPointer
},
_ => unimplemented!(),
function add_crate() {
pushd "$LIGHTNING_PATH/$1"
- RUSTC_BOOTSTRAP=1 cargo rustc --profile=check $3 -- --cfg=c_bindings -Zunpretty=expanded > /tmp/$1-crate-source.txt
+ RUSTC_BOOTSTRAP=1 cargo rustc --profile=check --no-default-features $3 -- --cfg=c_bindings -Zunpretty=expanded > /tmp/$1-crate-source.txt
popd
if [ "$HOST_PLATFORM" = "host: x86_64-apple-darwin" ]; then
sed -i".original" "1i\\
rm /tmp/$1-crate-source.txt
if [ "$HOST_PLATFORM" = "host: x86_64-apple-darwin" ]; then
# OSX sed is for some reason not compatible with GNU sed
- sed -E -i '' 's|#?'$1' = \{ .*|'$1' = \{ path = "'"$LIGHTNING_PATH"'/'$1'" '"$4"' }|' lightning-c-bindings/Cargo.toml
+ sed -E -i '' 's|#*'$1' = \{ .*|'$1' = \{ path = "'"$LIGHTNING_PATH"'/'$1'", default-features = false }|' lightning-c-bindings/Cargo.toml
else
- sed -E -i 's|#?'$1' = \{ .*|'$1' = \{ path = "'"$LIGHTNING_PATH"'/'$1'" '"$4"' }|' lightning-c-bindings/Cargo.toml
+ sed -E -i 's|#*'$1' = \{ .*|'$1' = \{ path = "'"$LIGHTNING_PATH"'/'$1'", default-features = false }|' lightning-c-bindings/Cargo.toml
fi
}
echo > /tmp/crate-source.txt
if [ "$2" = "true" ]; then
- add_crate lightning lightning --features=std ', features = ["std"]'
+ add_crate lightning lightning --features=std
add_crate "lightning-persister" "lightning_persister"
add_crate "lightning-background-processor" "lightning_background_processor"
+ add_crate "lightning-invoice" "lightning_invoice"
+ CARGO_BUILD_ARGS="--features=std"
else
- add_crate lightning lightning --features=no-std ', features = ["no-std"]'
+ add_crate lightning lightning --features=no-std
drop_crate "lightning-persister"
drop_crate "lightning-background-processor"
+ drop_crate "lightning-invoice"
+ CARGO_BUILD_ARGS="--features=no-std"
fi
-add_crate "lightning-invoice" "lightning_invoice"
cat /tmp/crate-source.txt | RUST_BACKTRACE=1 "$BIN" "$OUT/" "$OUT_TEMPL" "$OUT_F" "$OUT_CPP"
# Now cd to lightning-c-bindings, build the generated bindings, and call cbindgen to build a C header file
cd lightning-c-bindings
-RUSTFLAGS="$RUSTFLAGS --cfg=test_mod_pointers" cargo build
+RUSTFLAGS="$RUSTFLAGS --cfg=test_mod_pointers" cargo build $CARGO_BUILD_ARGS
if [ "$CFLAGS_aarch64_apple_darwin" != "" ]; then
- RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=apple-a14" cargo build --target aarch64-apple-darwin
+ RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=apple-a14" cargo build $CARGO_BUILD_ARGS --target aarch64-apple-darwin
fi
cbindgen -v --config cbindgen.toml -o include/lightning.h >/dev/null 2>&1
LLVM_V=$(rustc +nightly --version --verbose | grep "LLVM version" | awk '{ print substr($3, 0, 2); }')
if [ -x "$(which clang-$LLVM_V)" ]; then
cargo +nightly clean
- cargo +nightly rustc -Zbuild-std=std,panic_abort --target x86_64-unknown-linux-gnu -v -- -Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes
+ cargo +nightly rustc $CARGO_BUILD_ARGS -Zbuild-std=std,panic_abort --target x86_64-unknown-linux-gnu -v -- -Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes
mv target/x86_64-unknown-linux-gnu/debug/libldk.* target/debug/
# Sadly, std doesn't seem to compile into something that is memsan-safe as of Aug 2020,
sed -i.bk 's/,"cdylib"]/]/g' Cargo.toml
fi
if [ "$CFLAGS_aarch64_apple_darwin" != "" ]; then
- RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=apple-a14" RUSTC_BOOTSTRAP=1 cargo rustc --target aarch64-apple-darwin -v -- -Zsanitizer=address -Cforce-frame-pointers=yes || ( mv Cargo.toml.bk Cargo.toml; exit 1)
+ RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=apple-a14" RUSTC_BOOTSTRAP=1 cargo rustc $CARGO_BUILD_ARGS --target aarch64-apple-darwin -v -- -Zsanitizer=address -Cforce-frame-pointers=yes || ( mv Cargo.toml.bk Cargo.toml; exit 1)
fi
- RUSTFLAGS="$RUSTFLAGS --cfg=test_mod_pointers" RUSTC_BOOTSTRAP=1 cargo rustc -v -- -Zsanitizer=address -Cforce-frame-pointers=yes || ( mv Cargo.toml.bk Cargo.toml; exit 1)
+ RUSTFLAGS="$RUSTFLAGS --cfg=test_mod_pointers" RUSTC_BOOTSTRAP=1 cargo rustc $CARGO_BUILD_ARGS -v -- -Zsanitizer=address -Cforce-frame-pointers=yes || ( mv Cargo.toml.bk Cargo.toml; exit 1)
mv Cargo.toml.bk Cargo.toml
# First the C demo app...
# Now build with LTO on on both C++ and rust, but without cross-language LTO:
# Clear stale release build artifacts from previous runs
cargo clean --release
-CARGO_PROFILE_RELEASE_LTO=true cargo rustc -v --release -- -C lto
+CARGO_PROFILE_RELEASE_LTO=true cargo rustc $CARGO_BUILD_ARGS -v --release -- -C lto
if [ "$2" = "true" ]; then
clang++ $LOCAL_CFLAGS -std=c++11 -O2 demo.cpp target/release/libldk.a -ldl
fi
if clang -nostdlib -o /dev/null --target=wasm32-wasi -Wl,--no-entry genbindings_wasm_test_file.c > /dev/null 2>&1; then
# And if it does, build a WASM binary without capturing errors
export CFLAGS_wasm32_wasi="$BASE_CFLAGS -target wasm32"
- cargo rustc -v --target=wasm32-wasi
+ RUSTFLAGS="$RUSTFLAGS --cfg=test_mod_pointers" cargo rustc $CARGO_BUILD_ARGS -v --target=wasm32-wasi
export CFLAGS_wasm32_wasi="$BASE_CFLAGS -target wasm32 -Os"
- CARGO_PROFILE_RELEASE_LTO=true cargo rustc -v --release --target=wasm32-wasi -- -C embed-bitcode=yes -C opt-level=s -C linker-plugin-lto -C lto
+ CARGO_PROFILE_RELEASE_LTO=true cargo rustc $CARGO_BUILD_ARGS -v --release --target=wasm32-wasi -- -C embed-bitcode=yes -C opt-level=s -C linker-plugin-lto -C lto
else
echo "Cannot build WASM lib as clang does not seem to support the wasm32-wasi target"
fi
EXTRA_ENV_TARGET=$(echo "${EXTRA_TARGETS[$IDX]}" | sed 's/-/_/g')
export CFLAGS_$EXTRA_ENV_TARGET="$BASE_CFLAGS"
export CC_$EXTRA_ENV_TARGET=${EXTRA_CCS[$IDX]}
- RUSTFLAGS="$BASE_RUSTFLAGS -C linker=${EXTRA_CCS[$IDX]}" CARGO_PROFILE_RELEASE_LTO=true cargo rustc -v --release --target "${EXTRA_TARGETS[$IDX]}" -- -C lto
+ RUSTFLAGS="$BASE_RUSTFLAGS -C linker=${EXTRA_CCS[$IDX]}" CARGO_PROFILE_RELEASE_LTO=true cargo rustc $CARGO_BUILD_ARGS -v --release --target "${EXTRA_TARGETS[$IDX]}" -- -C lto
done
if [ "$CLANGPP" != "" -a "$LLD" != "" ]; then
done
export CFLAGS_aarch64_apple_darwin="$CFLAGS_aarch64_apple_darwin -O3 -fPIC -fembed-bitcode"
LINK_ARG_FLAGS="$LINK_ARG_FLAGS -C link-arg="-isysroot$(xcrun --show-sdk-path)" -C link-arg=-mmacosx-version-min=10.9"
- RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=apple-a14" CARGO_PROFILE_RELEASE_LTO=true cargo rustc -v --release --target aarch64-apple-darwin -- -C linker-plugin-lto -C lto -C linker=$CLANG $LINK_ARG_FLAGS -C link-arg=-mcpu=apple-a14
+ RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=apple-a14" CARGO_PROFILE_RELEASE_LTO=true cargo rustc $CARGO_BUILD_ARGS -v --release --target aarch64-apple-darwin -- -C linker-plugin-lto -C lto -C linker=$CLANG $LINK_ARG_FLAGS -C link-arg=-mcpu=apple-a14
fi
export CFLAGS_$ENV_TARGET="$BASE_CFLAGS -O3 -fPIC -fembed-bitcode -march=sandybridge -mcpu=sandybridge -mtune=sandybridge"
# Rust doesn't recognize CFLAGS changes, so we need to clean build artifacts
cargo clean --release
- CARGO_PROFILE_RELEASE_LTO=true cargo rustc -v --release -- -C linker-plugin-lto -C lto -C linker=$CLANG $LINK_ARG_FLAGS -C link-arg=-march=sandybridge -C link-arg=-mcpu=sandybridge -C link-arg=-mtune=sandybridge
+ CARGO_PROFILE_RELEASE_LTO=true cargo rustc $CARGO_BUILD_ARGS -v --release -- -C linker-plugin-lto -C lto -C linker=$CLANG $LINK_ARG_FLAGS -C link-arg=-march=sandybridge -C link-arg=-mcpu=sandybridge -C link-arg=-mtune=sandybridge
if [ "$2" = "true" ]; then
$CLANGPP $LOCAL_CFLAGS -flto -fuse-ld=$LLD -O2 demo.cpp target/release/libldk.a -ldl
fi
else
if [ "$CFLAGS_aarch64_apple_darwin" != "" ]; then
- RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=apple-a14" CARGO_PROFILE_RELEASE_LTO=true cargo rustc -v --release --target aarch64-apple-darwin -- -C lto
+ RUSTFLAGS="$BASE_RUSTFLAGS -C target-cpu=apple-a14" CARGO_PROFILE_RELEASE_LTO=true cargo rustc $CARGO_BUILD_ARGS -v --release --target aarch64-apple-darwin -- -C lto
fi
echo "WARNING: Building with cross-language LTO is not avilable without clang-$RUSTC_LLVM_V"
fi
# Note that the following line is matched exactly by genbindings to turn off dylib creation
,"cdylib"]
+[features]
+no-std = ["bitcoin/no-std", "lightning/no-std", "core2"]
+std = ["bitcoin/std", "lightning/std"]
+
[dependencies]
-bitcoin = "0.27"
+bitcoin = { version = "0.27", default-features = false }
secp256k1 = { version = "0.20.3", features = ["global-context-less-secure"] }
# Note that the following line is matched by genbindings to update the path
-lightning = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "80ea2e51cdd3decf084574dee365065d782f7e8c", features = ["std"] }
-lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "80ea2e51cdd3decf084574dee365065d782f7e8c" }
-lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "80ea2e51cdd3decf084574dee365065d782f7e8c" }
-lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", rev = "80ea2e51cdd3decf084574dee365065d782f7e8c" }
+lightning = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.104-bindings", default-features = false }
+lightning-persister = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.104-bindings", default-features = false }
+lightning-invoice = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.104-bindings", default-features = false }
+lightning-background-processor = { git = "https://github.com/lightningdevkit/rust-lightning", branch = "0.0.104-bindings", default-features = false }
+
+core2 = { version = "0.3.0", optional = true, default-features = false }
# Always force panic=abort, further options are set in the genbindings.sh build script
[profile.dev]
+
+use alloc::str::FromStr;
+use core::ffi::c_void;
+use core::convert::Infallible;
+use bitcoin::hashes::Hash;
+use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
+
#[repr(C)]
/// The contents of CResult_SecretKeyErrorZ
pub union CResult_SecretKeyErrorZPtr {
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::SecretKey, crate::c_types::Secp256k1Error>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_SecretKeyErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_SecretKeyErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::PublicKey, crate::c_types::Secp256k1Error>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_PublicKeyErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_PublicKeyErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::chan_utils::TxCreationKeys, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_TxCreationKeysDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_TxCreationKeysDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::chan_utils::ChannelPublicKeys, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ChannelPublicKeysDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ChannelPublicKeysDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::chan_utils::TxCreationKeys, crate::c_types::Secp256k1Error>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_TxCreationKeysErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_TxCreationKeysErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::chan_utils::HTLCOutputInCommitment, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_HTLCOutputInCommitmentDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_HTLCOutputInCommitmentDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_CounterpartyChannelTransactionParametersDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::chan_utils::ChannelTransactionParameters, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ChannelTransactionParametersDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ChannelTransactionParametersDecodeErrorZPtr { err }
};
Self {
impl CVec_SignatureZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::Signature> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Signature] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::c_types::Signature>> for CVec_SignatureZ {
impl Drop for CVec_SignatureZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_SignatureZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::chan_utils::HolderCommitmentTransaction, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_HolderCommitmentTransactionDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_HolderCommitmentTransactionDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::chan_utils::BuiltCommitmentTransaction, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_BuiltCommitmentTransactionDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_BuiltCommitmentTransactionDecodeErrorZPtr { err }
};
Self {
/// Reading from this pointer when `result_ok` is not set is undefined.
pub result: *mut crate::lightning::ln::chan_utils::TrustedClosingTransaction,
/// Note that this value is always NULL, as there are no contents in the Err variant
- pub err: *mut std::ffi::c_void,
+ pub err: *mut core::ffi::c_void,
}
#[repr(C)]
/// A CResult_TrustedClosingTransactionNoneZ represents the result of a fallible operation,
pub extern "C" fn CResult_TrustedClosingTransactionNoneZ_err() -> CResult_TrustedClosingTransactionNoneZ {
CResult_TrustedClosingTransactionNoneZ {
contents: CResult_TrustedClosingTransactionNoneZPtr {
- err: std::ptr::null_mut(),
+ err: core::ptr::null_mut(),
},
result_ok: false,
}
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::chan_utils::TrustedClosingTransaction, ()>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_TrustedClosingTransactionNoneZPtr { result }
} else {
let _ = unsafe { Box::from_raw(o.contents.err) };
- o.contents.err = std::ptr::null_mut();
- CResult_TrustedClosingTransactionNoneZPtr { err: std::ptr::null_mut() }
+ o.contents.err = core::ptr::null_mut();
+ CResult_TrustedClosingTransactionNoneZPtr { err: core::ptr::null_mut() }
};
Self {
contents,
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::chan_utils::CommitmentTransaction, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_CommitmentTransactionDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_CommitmentTransactionDecodeErrorZPtr { err }
};
Self {
/// Reading from this pointer when `result_ok` is not set is undefined.
pub result: *mut crate::lightning::ln::chan_utils::TrustedCommitmentTransaction,
/// Note that this value is always NULL, as there are no contents in the Err variant
- pub err: *mut std::ffi::c_void,
+ pub err: *mut core::ffi::c_void,
}
#[repr(C)]
/// A CResult_TrustedCommitmentTransactionNoneZ represents the result of a fallible operation,
pub extern "C" fn CResult_TrustedCommitmentTransactionNoneZ_err() -> CResult_TrustedCommitmentTransactionNoneZ {
CResult_TrustedCommitmentTransactionNoneZ {
contents: CResult_TrustedCommitmentTransactionNoneZPtr {
- err: std::ptr::null_mut(),
+ err: core::ptr::null_mut(),
},
result_ok: false,
}
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::chan_utils::TrustedCommitmentTransaction, ()>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_TrustedCommitmentTransactionNoneZPtr { result }
} else {
let _ = unsafe { Box::from_raw(o.contents.err) };
- o.contents.err = std::ptr::null_mut();
- CResult_TrustedCommitmentTransactionNoneZPtr { err: std::ptr::null_mut() }
+ o.contents.err = core::ptr::null_mut();
+ CResult_TrustedCommitmentTransactionNoneZPtr { err: core::ptr::null_mut() }
};
Self {
contents,
/// Reading from this pointer when `result_ok` is not set is undefined.
pub result: *mut crate::c_types::derived::CVec_SignatureZ,
/// Note that this value is always NULL, as there are no contents in the Err variant
- pub err: *mut std::ffi::c_void,
+ pub err: *mut core::ffi::c_void,
}
#[repr(C)]
/// A CResult_CVec_SignatureZNoneZ represents the result of a fallible operation,
pub extern "C" fn CResult_CVec_SignatureZNoneZ_err() -> CResult_CVec_SignatureZNoneZ {
CResult_CVec_SignatureZNoneZ {
contents: CResult_CVec_SignatureZNoneZPtr {
- err: std::ptr::null_mut(),
+ err: core::ptr::null_mut(),
},
result_ok: false,
}
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::CVec_SignatureZ, ()>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_CVec_SignatureZNoneZPtr { result }
} else {
let _ = unsafe { Box::from_raw(o.contents.err) };
- o.contents.err = std::ptr::null_mut();
- CResult_CVec_SignatureZNoneZPtr { err: std::ptr::null_mut() }
+ o.contents.err = core::ptr::null_mut();
+ CResult_CVec_SignatureZNoneZPtr { err: core::ptr::null_mut() }
};
Self {
contents,
} }
} else {
Self { result_ok: false, contents: CResult_CVec_SignatureZNoneZPtr {
- err: std::ptr::null_mut()
+ err: core::ptr::null_mut()
} }
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::script::ShutdownScript, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ShutdownScriptDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ShutdownScriptDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::script::ShutdownScript, crate::lightning::ln::script::InvalidShutdownScript>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ShutdownScriptInvalidShutdownScriptZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ShutdownScriptInvalidShutdownScriptZPtr { err }
};
Self {
/// The contents of CResult_NoneErrorZ
pub union CResult_NoneErrorZPtr {
/// Note that this value is always NULL, as there are no contents in the OK variant
- pub result: *mut std::ffi::c_void,
+ pub result: *mut core::ffi::c_void,
/// A pointer to the contents in the error state.
/// Reading from this pointer when `result_ok` is set is undefined.
pub err: *mut crate::c_types::IOError,
pub extern "C" fn CResult_NoneErrorZ_ok() -> CResult_NoneErrorZ {
CResult_NoneErrorZ {
contents: CResult_NoneErrorZPtr {
- result: std::ptr::null_mut(),
+ result: core::ptr::null_mut(),
},
result_ok: true,
}
fn from(mut o: crate::c_types::CResultTempl<(), crate::c_types::IOError>) -> Self {
let contents = if o.result_ok {
let _ = unsafe { Box::from_raw(o.contents.result) };
- o.contents.result = std::ptr::null_mut();
- CResult_NoneErrorZPtr { result: std::ptr::null_mut() }
+ o.contents.result = core::ptr::null_mut();
+ CResult_NoneErrorZPtr { result: core::ptr::null_mut() }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_NoneErrorZPtr { err }
};
Self {
fn clone(&self) -> Self {
if self.result_ok {
Self { result_ok: true, contents: CResult_NoneErrorZPtr {
- result: std::ptr::null_mut()
+ result: core::ptr::null_mut()
} }
} else {
Self { result_ok: false, contents: CResult_NoneErrorZPtr {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::routing::router::RouteHop, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_RouteHopDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_RouteHopDecodeErrorZPtr { err }
};
Self {
impl CVec_RouteHopZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning::routing::router::RouteHop> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHop] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::lightning::routing::router::RouteHop>> for CVec_RouteHopZ {
impl Drop for CVec_RouteHopZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_RouteHopZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
impl CVec_CVec_RouteHopZZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::derived::CVec_RouteHopZ> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::CVec_RouteHopZ] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::c_types::derived::CVec_RouteHopZ>> for CVec_CVec_RouteHopZZ {
impl Drop for CVec_CVec_RouteHopZZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_CVec_RouteHopZZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::routing::router::Route, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_RouteDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_RouteDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::routing::router::RouteParameters, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_RouteParametersDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_RouteParametersDecodeErrorZPtr { err }
};
Self {
impl CVec_RouteHintZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning::routing::router::RouteHint> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHint] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::lightning::routing::router::RouteHint>> for CVec_RouteHintZ {
impl Drop for CVec_RouteHintZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_RouteHintZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::routing::router::Payee, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_PayeeDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_PayeeDecodeErrorZPtr { err }
};
Self {
impl CVec_RouteHintHopZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning::routing::router::RouteHintHop> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::routing::router::RouteHintHop] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::lightning::routing::router::RouteHintHop>> for CVec_RouteHintHopZ {
impl Drop for CVec_RouteHintHopZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_RouteHintHopZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::routing::router::RouteHint, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_RouteHintDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_RouteHintDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::routing::router::RouteHintHop, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_RouteHintHopDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_RouteHintHopDecodeErrorZPtr { err }
};
Self {
impl CVec_ChannelDetailsZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning::ln::channelmanager::ChannelDetails> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::channelmanager::ChannelDetails] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::lightning::ln::channelmanager::ChannelDetails>> for CVec_ChannelDetailsZ {
impl Drop for CVec_ChannelDetailsZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_ChannelDetailsZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::routing::router::Route, crate::lightning::ln::msgs::LightningError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_RouteLightningErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_RouteLightningErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::TxOut, crate::lightning::chain::AccessError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_TxOutAccessErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_TxOutAccessErrorZPtr { err }
};
Self {
impl CVec_C2Tuple_usizeTransactionZZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::derived::C2Tuple_usizeTransactionZ> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_usizeTransactionZ] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::c_types::derived::C2Tuple_usizeTransactionZ>> for CVec_C2Tuple_usizeTransactionZZ {
impl Drop for CVec_C2Tuple_usizeTransactionZZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_C2Tuple_usizeTransactionZZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
impl CVec_TxidZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::ThirtyTwoBytes> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::ThirtyTwoBytes] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::c_types::ThirtyTwoBytes>> for CVec_TxidZ {
impl Drop for CVec_TxidZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_TxidZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
/// The contents of CResult_NoneChannelMonitorUpdateErrZ
pub union CResult_NoneChannelMonitorUpdateErrZPtr {
/// Note that this value is always NULL, as there are no contents in the OK variant
- pub result: *mut std::ffi::c_void,
+ pub result: *mut core::ffi::c_void,
/// A pointer to the contents in the error state.
/// Reading from this pointer when `result_ok` is set is undefined.
pub err: *mut crate::lightning::chain::ChannelMonitorUpdateErr,
pub extern "C" fn CResult_NoneChannelMonitorUpdateErrZ_ok() -> CResult_NoneChannelMonitorUpdateErrZ {
CResult_NoneChannelMonitorUpdateErrZ {
contents: CResult_NoneChannelMonitorUpdateErrZPtr {
- result: std::ptr::null_mut(),
+ result: core::ptr::null_mut(),
},
result_ok: true,
}
fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::chain::ChannelMonitorUpdateErr>) -> Self {
let contents = if o.result_ok {
let _ = unsafe { Box::from_raw(o.contents.result) };
- o.contents.result = std::ptr::null_mut();
- CResult_NoneChannelMonitorUpdateErrZPtr { result: std::ptr::null_mut() }
+ o.contents.result = core::ptr::null_mut();
+ CResult_NoneChannelMonitorUpdateErrZPtr { result: core::ptr::null_mut() }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_NoneChannelMonitorUpdateErrZPtr { err }
};
Self {
fn clone(&self) -> Self {
if self.result_ok {
Self { result_ok: true, contents: CResult_NoneChannelMonitorUpdateErrZPtr {
- result: std::ptr::null_mut()
+ result: core::ptr::null_mut()
} }
} else {
Self { result_ok: false, contents: CResult_NoneChannelMonitorUpdateErrZPtr {
impl CVec_MonitorEventZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning::chain::channelmonitor::MonitorEvent> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::MonitorEvent] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::lightning::chain::channelmonitor::MonitorEvent>> for CVec_MonitorEventZ {
impl Drop for CVec_MonitorEventZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_MonitorEventZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::COption_ClosureReasonZ, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_COption_ClosureReasonZDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_COption_ClosureReasonZDecodeErrorZPtr { err }
};
Self {
impl CVec_SpendableOutputDescriptorZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning::chain::keysinterface::SpendableOutputDescriptor> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::keysinterface::SpendableOutputDescriptor] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::lightning::chain::keysinterface::SpendableOutputDescriptor>> for CVec_SpendableOutputDescriptorZ {
impl Drop for CVec_SpendableOutputDescriptorZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_SpendableOutputDescriptorZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::COption_EventZ, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_COption_EventZDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_COption_EventZDecodeErrorZPtr { err }
};
Self {
impl CVec_MessageSendEventZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning::util::events::MessageSendEvent> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::util::events::MessageSendEvent] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::lightning::util::events::MessageSendEvent>> for CVec_MessageSendEventZ {
impl Drop for CVec_MessageSendEventZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_MessageSendEventZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::routing::scoring::ScoringParameters, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ScoringParametersDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ScoringParametersDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::routing::scoring::Scorer, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ScorerDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ScorerDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::features::InitFeatures, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_InitFeaturesDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_InitFeaturesDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::features::ChannelFeatures, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ChannelFeaturesDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ChannelFeaturesDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::features::NodeFeatures, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_NodeFeaturesDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_NodeFeaturesDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::features::InvoiceFeatures, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_InvoiceFeaturesDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_InvoiceFeaturesDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::features::ChannelTypeFeatures, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ChannelTypeFeaturesDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ChannelTypeFeaturesDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::chain::keysinterface::DelayedPaymentOutputDescriptor, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_DelayedPaymentOutputDescriptorDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::chain::keysinterface::StaticPaymentOutputDescriptor, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_StaticPaymentOutputDescriptorDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::chain::keysinterface::SpendableOutputDescriptor, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_SpendableOutputDescriptorDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_SpendableOutputDescriptorDecodeErrorZPtr { err }
};
Self {
/// The contents of CResult_NoneNoneZ
pub union CResult_NoneNoneZPtr {
/// Note that this value is always NULL, as there are no contents in the OK variant
- pub result: *mut std::ffi::c_void,
+ pub result: *mut core::ffi::c_void,
/// Note that this value is always NULL, as there are no contents in the Err variant
- pub err: *mut std::ffi::c_void,
+ pub err: *mut core::ffi::c_void,
}
#[repr(C)]
/// A CResult_NoneNoneZ represents the result of a fallible operation,
pub extern "C" fn CResult_NoneNoneZ_ok() -> CResult_NoneNoneZ {
CResult_NoneNoneZ {
contents: CResult_NoneNoneZPtr {
- result: std::ptr::null_mut(),
+ result: core::ptr::null_mut(),
},
result_ok: true,
}
pub extern "C" fn CResult_NoneNoneZ_err() -> CResult_NoneNoneZ {
CResult_NoneNoneZ {
contents: CResult_NoneNoneZPtr {
- err: std::ptr::null_mut(),
+ err: core::ptr::null_mut(),
},
result_ok: false,
}
fn from(mut o: crate::c_types::CResultTempl<(), ()>) -> Self {
let contents = if o.result_ok {
let _ = unsafe { Box::from_raw(o.contents.result) };
- o.contents.result = std::ptr::null_mut();
- CResult_NoneNoneZPtr { result: std::ptr::null_mut() }
+ o.contents.result = core::ptr::null_mut();
+ CResult_NoneNoneZPtr { result: core::ptr::null_mut() }
} else {
let _ = unsafe { Box::from_raw(o.contents.err) };
- o.contents.err = std::ptr::null_mut();
- CResult_NoneNoneZPtr { err: std::ptr::null_mut() }
+ o.contents.err = core::ptr::null_mut();
+ CResult_NoneNoneZPtr { err: core::ptr::null_mut() }
};
Self {
contents,
fn clone(&self) -> Self {
if self.result_ok {
Self { result_ok: true, contents: CResult_NoneNoneZPtr {
- result: std::ptr::null_mut()
+ result: core::ptr::null_mut()
} }
} else {
Self { result_ok: false, contents: CResult_NoneNoneZPtr {
- err: std::ptr::null_mut()
+ err: core::ptr::null_mut()
} }
}
}
/// Reading from this pointer when `result_ok` is not set is undefined.
pub result: *mut crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ,
/// Note that this value is always NULL, as there are no contents in the Err variant
- pub err: *mut std::ffi::c_void,
+ pub err: *mut core::ffi::c_void,
}
#[repr(C)]
/// A CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ represents the result of a fallible operation,
pub extern "C" fn CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err() -> CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ {
contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr {
- err: std::ptr::null_mut(),
+ err: core::ptr::null_mut(),
},
result_ok: false,
}
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::C2Tuple_SignatureCVec_SignatureZZ, ()>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { result }
} else {
let _ = unsafe { Box::from_raw(o.contents.err) };
- o.contents.err = std::ptr::null_mut();
- CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { err: std::ptr::null_mut() }
+ o.contents.err = core::ptr::null_mut();
+ CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr { err: core::ptr::null_mut() }
};
Self {
contents,
} }
} else {
Self { result_ok: false, contents: CResult_C2Tuple_SignatureCVec_SignatureZZNoneZPtr {
- err: std::ptr::null_mut()
+ err: core::ptr::null_mut()
} }
}
}
/// Reading from this pointer when `result_ok` is not set is undefined.
pub result: *mut crate::c_types::Signature,
/// Note that this value is always NULL, as there are no contents in the Err variant
- pub err: *mut std::ffi::c_void,
+ pub err: *mut core::ffi::c_void,
}
#[repr(C)]
/// A CResult_SignatureNoneZ represents the result of a fallible operation,
pub extern "C" fn CResult_SignatureNoneZ_err() -> CResult_SignatureNoneZ {
CResult_SignatureNoneZ {
contents: CResult_SignatureNoneZPtr {
- err: std::ptr::null_mut(),
+ err: core::ptr::null_mut(),
},
result_ok: false,
}
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::Signature, ()>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_SignatureNoneZPtr { result }
} else {
let _ = unsafe { Box::from_raw(o.contents.err) };
- o.contents.err = std::ptr::null_mut();
- CResult_SignatureNoneZPtr { err: std::ptr::null_mut() }
+ o.contents.err = core::ptr::null_mut();
+ CResult_SignatureNoneZPtr { err: core::ptr::null_mut() }
};
Self {
contents,
} }
} else {
Self { result_ok: false, contents: CResult_SignatureNoneZPtr {
- err: std::ptr::null_mut()
+ err: core::ptr::null_mut()
} }
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::chain::keysinterface::Sign, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_SignDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_SignDecodeErrorZPtr { err }
};
Self {
impl CVec_u8Z {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<u8> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[u8] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<u8>> for CVec_u8Z {
impl Drop for CVec_u8Z {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_u8Z {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
/// Reading from this pointer when `result_ok` is not set is undefined.
pub result: *mut crate::c_types::RecoverableSignature,
/// Note that this value is always NULL, as there are no contents in the Err variant
- pub err: *mut std::ffi::c_void,
+ pub err: *mut core::ffi::c_void,
}
#[repr(C)]
/// A CResult_RecoverableSignatureNoneZ represents the result of a fallible operation,
pub extern "C" fn CResult_RecoverableSignatureNoneZ_err() -> CResult_RecoverableSignatureNoneZ {
CResult_RecoverableSignatureNoneZ {
contents: CResult_RecoverableSignatureNoneZPtr {
- err: std::ptr::null_mut(),
+ err: core::ptr::null_mut(),
},
result_ok: false,
}
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::RecoverableSignature, ()>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_RecoverableSignatureNoneZPtr { result }
} else {
let _ = unsafe { Box::from_raw(o.contents.err) };
- o.contents.err = std::ptr::null_mut();
- CResult_RecoverableSignatureNoneZPtr { err: std::ptr::null_mut() }
+ o.contents.err = core::ptr::null_mut();
+ CResult_RecoverableSignatureNoneZPtr { err: core::ptr::null_mut() }
};
Self {
contents,
} }
} else {
Self { result_ok: false, contents: CResult_RecoverableSignatureNoneZPtr {
- err: std::ptr::null_mut()
+ err: core::ptr::null_mut()
} }
}
}
impl CVec_CVec_u8ZZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::derived::CVec_u8Z> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::CVec_u8Z] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::c_types::derived::CVec_u8Z>> for CVec_CVec_u8ZZ {
impl Drop for CVec_CVec_u8ZZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_CVec_u8ZZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
/// Reading from this pointer when `result_ok` is not set is undefined.
pub result: *mut crate::c_types::derived::CVec_CVec_u8ZZ,
/// Note that this value is always NULL, as there are no contents in the Err variant
- pub err: *mut std::ffi::c_void,
+ pub err: *mut core::ffi::c_void,
}
#[repr(C)]
/// A CResult_CVec_CVec_u8ZZNoneZ represents the result of a fallible operation,
pub extern "C" fn CResult_CVec_CVec_u8ZZNoneZ_err() -> CResult_CVec_CVec_u8ZZNoneZ {
CResult_CVec_CVec_u8ZZNoneZ {
contents: CResult_CVec_CVec_u8ZZNoneZPtr {
- err: std::ptr::null_mut(),
+ err: core::ptr::null_mut(),
},
result_ok: false,
}
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::CVec_CVec_u8ZZ, ()>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_CVec_CVec_u8ZZNoneZPtr { result }
} else {
let _ = unsafe { Box::from_raw(o.contents.err) };
- o.contents.err = std::ptr::null_mut();
- CResult_CVec_CVec_u8ZZNoneZPtr { err: std::ptr::null_mut() }
+ o.contents.err = core::ptr::null_mut();
+ CResult_CVec_CVec_u8ZZNoneZPtr { err: core::ptr::null_mut() }
};
Self {
contents,
} }
} else {
Self { result_ok: false, contents: CResult_CVec_CVec_u8ZZNoneZPtr {
- err: std::ptr::null_mut()
+ err: core::ptr::null_mut()
} }
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::chain::keysinterface::InMemorySigner, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_InMemorySignerDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_InMemorySignerDecodeErrorZPtr { err }
};
Self {
impl CVec_TxOutZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::TxOut> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::TxOut] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::c_types::TxOut>> for CVec_TxOutZ {
impl Drop for CVec_TxOutZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_TxOutZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
/// Reading from this pointer when `result_ok` is not set is undefined.
pub result: *mut crate::c_types::Transaction,
/// Note that this value is always NULL, as there are no contents in the Err variant
- pub err: *mut std::ffi::c_void,
+ pub err: *mut core::ffi::c_void,
}
#[repr(C)]
/// A CResult_TransactionNoneZ represents the result of a fallible operation,
pub extern "C" fn CResult_TransactionNoneZ_err() -> CResult_TransactionNoneZ {
CResult_TransactionNoneZ {
contents: CResult_TransactionNoneZPtr {
- err: std::ptr::null_mut(),
+ err: core::ptr::null_mut(),
},
result_ok: false,
}
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::Transaction, ()>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_TransactionNoneZPtr { result }
} else {
let _ = unsafe { Box::from_raw(o.contents.err) };
- o.contents.err = std::ptr::null_mut();
- CResult_TransactionNoneZPtr { err: std::ptr::null_mut() }
+ o.contents.err = core::ptr::null_mut();
+ CResult_TransactionNoneZPtr { err: core::ptr::null_mut() }
};
Self {
contents,
} }
} else {
Self { result_ok: false, contents: CResult_TransactionNoneZPtr {
- err: std::ptr::null_mut()
+ err: core::ptr::null_mut()
} }
}
}
impl CVec_C2Tuple_BlockHashChannelMonitorZZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ>> for CVec_C2Tuple_BlockHashChannelMonitorZZ {
impl Drop for CVec_C2Tuple_BlockHashChannelMonitorZZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
#[repr(C)]
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::CVec_C2Tuple_BlockHashChannelMonitorZZ, crate::c_types::IOError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZPtr { err }
};
Self {
/// The contents of CResult_NoneAPIErrorZ
pub union CResult_NoneAPIErrorZPtr {
/// Note that this value is always NULL, as there are no contents in the OK variant
- pub result: *mut std::ffi::c_void,
+ pub result: *mut core::ffi::c_void,
/// A pointer to the contents in the error state.
/// Reading from this pointer when `result_ok` is set is undefined.
pub err: *mut crate::lightning::util::errors::APIError,
pub extern "C" fn CResult_NoneAPIErrorZ_ok() -> CResult_NoneAPIErrorZ {
CResult_NoneAPIErrorZ {
contents: CResult_NoneAPIErrorZPtr {
- result: std::ptr::null_mut(),
+ result: core::ptr::null_mut(),
},
result_ok: true,
}
fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::util::errors::APIError>) -> Self {
let contents = if o.result_ok {
let _ = unsafe { Box::from_raw(o.contents.result) };
- o.contents.result = std::ptr::null_mut();
- CResult_NoneAPIErrorZPtr { result: std::ptr::null_mut() }
+ o.contents.result = core::ptr::null_mut();
+ CResult_NoneAPIErrorZPtr { result: core::ptr::null_mut() }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_NoneAPIErrorZPtr { err }
};
Self {
fn clone(&self) -> Self {
if self.result_ok {
Self { result_ok: true, contents: CResult_NoneAPIErrorZPtr {
- result: std::ptr::null_mut()
+ result: core::ptr::null_mut()
} }
} else {
Self { result_ok: false, contents: CResult_NoneAPIErrorZPtr {
impl CVec_CResult_NoneAPIErrorZZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::derived::CResult_NoneAPIErrorZ> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::CResult_NoneAPIErrorZ] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::c_types::derived::CResult_NoneAPIErrorZ>> for CVec_CResult_NoneAPIErrorZZ {
impl Drop for CVec_CResult_NoneAPIErrorZZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_CResult_NoneAPIErrorZZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
impl CVec_APIErrorZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning::util::errors::APIError> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::util::errors::APIError] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::lightning::util::errors::APIError>> for CVec_APIErrorZ {
impl Drop for CVec_APIErrorZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_APIErrorZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::ThirtyTwoBytes, crate::lightning::util::errors::APIError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult__u832APIErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult__u832APIErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::ThirtyTwoBytes, crate::lightning::ln::channelmanager::PaymentSendFailure>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_PaymentIdPaymentSendFailureZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_PaymentIdPaymentSendFailureZPtr { err }
};
Self {
/// The contents of CResult_NonePaymentSendFailureZ
pub union CResult_NonePaymentSendFailureZPtr {
/// Note that this value is always NULL, as there are no contents in the OK variant
- pub result: *mut std::ffi::c_void,
+ pub result: *mut core::ffi::c_void,
/// A pointer to the contents in the error state.
/// Reading from this pointer when `result_ok` is set is undefined.
pub err: *mut crate::lightning::ln::channelmanager::PaymentSendFailure,
pub extern "C" fn CResult_NonePaymentSendFailureZ_ok() -> CResult_NonePaymentSendFailureZ {
CResult_NonePaymentSendFailureZ {
contents: CResult_NonePaymentSendFailureZPtr {
- result: std::ptr::null_mut(),
+ result: core::ptr::null_mut(),
},
result_ok: true,
}
fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::channelmanager::PaymentSendFailure>) -> Self {
let contents = if o.result_ok {
let _ = unsafe { Box::from_raw(o.contents.result) };
- o.contents.result = std::ptr::null_mut();
- CResult_NonePaymentSendFailureZPtr { result: std::ptr::null_mut() }
+ o.contents.result = core::ptr::null_mut();
+ CResult_NonePaymentSendFailureZPtr { result: core::ptr::null_mut() }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_NonePaymentSendFailureZPtr { err }
};
Self {
fn clone(&self) -> Self {
if self.result_ok {
Self { result_ok: true, contents: CResult_NonePaymentSendFailureZPtr {
- result: std::ptr::null_mut()
+ result: core::ptr::null_mut()
} }
} else {
Self { result_ok: false, contents: CResult_NonePaymentSendFailureZPtr {
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::C2Tuple_PaymentHashPaymentIdZ, crate::lightning::ln::channelmanager::PaymentSendFailure>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZPtr { err }
};
Self {
impl CVec_NetAddressZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning::ln::msgs::NetAddress> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::NetAddress] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::lightning::ln::msgs::NetAddress>> for CVec_NetAddressZ {
impl Drop for CVec_NetAddressZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_NetAddressZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
/// Reading from this pointer when `result_ok` is not set is undefined.
pub result: *mut crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ,
/// Note that this value is always NULL, as there are no contents in the Err variant
- pub err: *mut std::ffi::c_void,
+ pub err: *mut core::ffi::c_void,
}
#[repr(C)]
/// A CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ represents the result of a fallible operation,
pub extern "C" fn CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ_err() -> CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ {
CResult_C2Tuple_PaymentHashPaymentSecretZNoneZ {
contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr {
- err: std::ptr::null_mut(),
+ err: core::ptr::null_mut(),
},
result_ok: false,
}
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ, ()>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { result }
} else {
let _ = unsafe { Box::from_raw(o.contents.err) };
- o.contents.err = std::ptr::null_mut();
- CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { err: std::ptr::null_mut() }
+ o.contents.err = core::ptr::null_mut();
+ CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr { err: core::ptr::null_mut() }
};
Self {
contents,
} }
} else {
Self { result_ok: false, contents: CResult_C2Tuple_PaymentHashPaymentSecretZNoneZPtr {
- err: std::ptr::null_mut()
+ err: core::ptr::null_mut()
} }
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::C2Tuple_PaymentHashPaymentSecretZ, crate::lightning::util::errors::APIError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_C2Tuple_PaymentHashPaymentSecretZAPIErrorZPtr { err }
};
Self {
/// Reading from this pointer when `result_ok` is not set is undefined.
pub result: *mut crate::c_types::ThirtyTwoBytes,
/// Note that this value is always NULL, as there are no contents in the Err variant
- pub err: *mut std::ffi::c_void,
+ pub err: *mut core::ffi::c_void,
}
#[repr(C)]
/// A CResult_PaymentSecretNoneZ represents the result of a fallible operation,
pub extern "C" fn CResult_PaymentSecretNoneZ_err() -> CResult_PaymentSecretNoneZ {
CResult_PaymentSecretNoneZ {
contents: CResult_PaymentSecretNoneZPtr {
- err: std::ptr::null_mut(),
+ err: core::ptr::null_mut(),
},
result_ok: false,
}
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::ThirtyTwoBytes, ()>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_PaymentSecretNoneZPtr { result }
} else {
let _ = unsafe { Box::from_raw(o.contents.err) };
- o.contents.err = std::ptr::null_mut();
- CResult_PaymentSecretNoneZPtr { err: std::ptr::null_mut() }
+ o.contents.err = core::ptr::null_mut();
+ CResult_PaymentSecretNoneZPtr { err: core::ptr::null_mut() }
};
Self {
contents,
} }
} else {
Self { result_ok: false, contents: CResult_PaymentSecretNoneZPtr {
- err: std::ptr::null_mut()
+ err: core::ptr::null_mut()
} }
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::ThirtyTwoBytes, crate::lightning::util::errors::APIError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_PaymentSecretAPIErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_PaymentSecretAPIErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::ThirtyTwoBytes, crate::lightning::util::errors::APIError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_PaymentPreimageAPIErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_PaymentPreimageAPIErrorZPtr { err }
};
Self {
impl CVec_ChannelMonitorZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning::chain::channelmonitor::ChannelMonitor> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::ChannelMonitor] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::lightning::chain::channelmonitor::ChannelMonitor>> for CVec_ChannelMonitorZ {
impl Drop for CVec_ChannelMonitorZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
#[repr(C)]
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::C2Tuple_BlockHashChannelManagerZ, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::util::config::ChannelConfig, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ChannelConfigDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ChannelConfigDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::chain::transaction::OutPoint, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_OutPointDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_OutPointDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::COption_TypeZ, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_COption_TypeZDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_COption_TypeZDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::ThirtyTwoBytes, crate::lightning_invoice::payment::PaymentError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_PaymentIdPaymentErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_PaymentIdPaymentErrorZPtr { err }
};
Self {
/// Reading from this pointer when `result_ok` is not set is undefined.
pub result: *mut crate::lightning_invoice::SiPrefix,
/// Note that this value is always NULL, as there are no contents in the Err variant
- pub err: *mut std::ffi::c_void,
+ pub err: *mut core::ffi::c_void,
}
#[repr(C)]
/// A CResult_SiPrefixNoneZ represents the result of a fallible operation,
pub extern "C" fn CResult_SiPrefixNoneZ_err() -> CResult_SiPrefixNoneZ {
CResult_SiPrefixNoneZ {
contents: CResult_SiPrefixNoneZPtr {
- err: std::ptr::null_mut(),
+ err: core::ptr::null_mut(),
},
result_ok: false,
}
fn from(mut o: crate::c_types::CResultTempl<crate::lightning_invoice::SiPrefix, ()>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_SiPrefixNoneZPtr { result }
} else {
let _ = unsafe { Box::from_raw(o.contents.err) };
- o.contents.err = std::ptr::null_mut();
- CResult_SiPrefixNoneZPtr { err: std::ptr::null_mut() }
+ o.contents.err = core::ptr::null_mut();
+ CResult_SiPrefixNoneZPtr { err: core::ptr::null_mut() }
};
Self {
contents,
} }
} else {
Self { result_ok: false, contents: CResult_SiPrefixNoneZPtr {
- err: std::ptr::null_mut()
+ err: core::ptr::null_mut()
} }
}
}
/// Reading from this pointer when `result_ok` is not set is undefined.
pub result: *mut crate::lightning_invoice::Invoice,
/// Note that this value is always NULL, as there are no contents in the Err variant
- pub err: *mut std::ffi::c_void,
+ pub err: *mut core::ffi::c_void,
}
#[repr(C)]
/// A CResult_InvoiceNoneZ represents the result of a fallible operation,
pub extern "C" fn CResult_InvoiceNoneZ_err() -> CResult_InvoiceNoneZ {
CResult_InvoiceNoneZ {
contents: CResult_InvoiceNoneZPtr {
- err: std::ptr::null_mut(),
+ err: core::ptr::null_mut(),
},
result_ok: false,
}
fn from(mut o: crate::c_types::CResultTempl<crate::lightning_invoice::Invoice, ()>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_InvoiceNoneZPtr { result }
} else {
let _ = unsafe { Box::from_raw(o.contents.err) };
- o.contents.err = std::ptr::null_mut();
- CResult_InvoiceNoneZPtr { err: std::ptr::null_mut() }
+ o.contents.err = core::ptr::null_mut();
+ CResult_InvoiceNoneZPtr { err: core::ptr::null_mut() }
};
Self {
contents,
} }
} else {
Self { result_ok: false, contents: CResult_InvoiceNoneZPtr {
- err: std::ptr::null_mut()
+ err: core::ptr::null_mut()
} }
}
}
/// Reading from this pointer when `result_ok` is not set is undefined.
pub result: *mut crate::lightning_invoice::SignedRawInvoice,
/// Note that this value is always NULL, as there are no contents in the Err variant
- pub err: *mut std::ffi::c_void,
+ pub err: *mut core::ffi::c_void,
}
#[repr(C)]
/// A CResult_SignedRawInvoiceNoneZ represents the result of a fallible operation,
pub extern "C" fn CResult_SignedRawInvoiceNoneZ_err() -> CResult_SignedRawInvoiceNoneZ {
CResult_SignedRawInvoiceNoneZ {
contents: CResult_SignedRawInvoiceNoneZPtr {
- err: std::ptr::null_mut(),
+ err: core::ptr::null_mut(),
},
result_ok: false,
}
fn from(mut o: crate::c_types::CResultTempl<crate::lightning_invoice::SignedRawInvoice, ()>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_SignedRawInvoiceNoneZPtr { result }
} else {
let _ = unsafe { Box::from_raw(o.contents.err) };
- o.contents.err = std::ptr::null_mut();
- CResult_SignedRawInvoiceNoneZPtr { err: std::ptr::null_mut() }
+ o.contents.err = core::ptr::null_mut();
+ CResult_SignedRawInvoiceNoneZPtr { err: core::ptr::null_mut() }
};
Self {
contents,
} }
} else {
Self { result_ok: false, contents: CResult_SignedRawInvoiceNoneZPtr {
- err: std::ptr::null_mut()
+ err: core::ptr::null_mut()
} }
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::lightning_invoice::PayeePubKey, crate::c_types::Secp256k1Error>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_PayeePubKeyErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_PayeePubKeyErrorZPtr { err }
};
Self {
impl CVec_PrivateRouteZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning_invoice::PrivateRoute> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning_invoice::PrivateRoute] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::lightning_invoice::PrivateRoute>> for CVec_PrivateRouteZ {
impl Drop for CVec_PrivateRouteZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_PrivateRouteZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::lightning_invoice::PositiveTimestamp, crate::lightning_invoice::CreationError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_PositiveTimestampCreationErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_PositiveTimestampCreationErrorZPtr { err }
};
Self {
/// The contents of CResult_NoneSemanticErrorZ
pub union CResult_NoneSemanticErrorZPtr {
/// Note that this value is always NULL, as there are no contents in the OK variant
- pub result: *mut std::ffi::c_void,
+ pub result: *mut core::ffi::c_void,
/// A pointer to the contents in the error state.
/// Reading from this pointer when `result_ok` is set is undefined.
pub err: *mut crate::lightning_invoice::SemanticError,
pub extern "C" fn CResult_NoneSemanticErrorZ_ok() -> CResult_NoneSemanticErrorZ {
CResult_NoneSemanticErrorZ {
contents: CResult_NoneSemanticErrorZPtr {
- result: std::ptr::null_mut(),
+ result: core::ptr::null_mut(),
},
result_ok: true,
}
fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning_invoice::SemanticError>) -> Self {
let contents = if o.result_ok {
let _ = unsafe { Box::from_raw(o.contents.result) };
- o.contents.result = std::ptr::null_mut();
- CResult_NoneSemanticErrorZPtr { result: std::ptr::null_mut() }
+ o.contents.result = core::ptr::null_mut();
+ CResult_NoneSemanticErrorZPtr { result: core::ptr::null_mut() }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_NoneSemanticErrorZPtr { err }
};
Self {
fn clone(&self) -> Self {
if self.result_ok {
Self { result_ok: true, contents: CResult_NoneSemanticErrorZPtr {
- result: std::ptr::null_mut()
+ result: core::ptr::null_mut()
} }
} else {
Self { result_ok: false, contents: CResult_NoneSemanticErrorZPtr {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning_invoice::Invoice, crate::lightning_invoice::SemanticError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_InvoiceSemanticErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_InvoiceSemanticErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning_invoice::Description, crate::lightning_invoice::CreationError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_DescriptionCreationErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_DescriptionCreationErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning_invoice::ExpiryTime, crate::lightning_invoice::CreationError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ExpiryTimeCreationErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ExpiryTimeCreationErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning_invoice::PrivateRoute, crate::lightning_invoice::CreationError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_PrivateRouteCreationErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_PrivateRouteCreationErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::Str, crate::c_types::Secp256k1Error>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_StringErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_StringErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::chain::channelmonitor::ChannelMonitorUpdate, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ChannelMonitorUpdateDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ChannelMonitorUpdateDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::COption_MonitorEventZ, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_COption_MonitorEventZDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_COption_MonitorEventZDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::chain::channelmonitor::HTLCUpdate, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_HTLCUpdateDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_HTLCUpdateDecodeErrorZPtr { err }
};
Self {
impl CVec_C2Tuple_u32ScriptZZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::derived::C2Tuple_u32ScriptZ> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_u32ScriptZ] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::c_types::derived::C2Tuple_u32ScriptZ>> for CVec_C2Tuple_u32ScriptZZ {
impl Drop for CVec_C2Tuple_u32ScriptZZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_C2Tuple_u32ScriptZZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
impl CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ>> for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ {
impl Drop for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
impl CVec_EventZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning::util::events::Event> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::util::events::Event] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::lightning::util::events::Event>> for CVec_EventZ {
impl Drop for CVec_EventZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_EventZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
impl CVec_TransactionZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::Transaction> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::Transaction] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::c_types::Transaction>> for CVec_TransactionZ {
impl Drop for CVec_TransactionZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_TransactionZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
impl CVec_C2Tuple_u32TxOutZZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::derived::C2Tuple_u32TxOutZ> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_u32TxOutZ] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::c_types::derived::C2Tuple_u32TxOutZ>> for CVec_C2Tuple_u32TxOutZZ {
impl Drop for CVec_C2Tuple_u32TxOutZZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_C2Tuple_u32TxOutZZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
impl CVec_TransactionOutputsZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::c_types::derived::C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ>> for CVec_TransactionOutputsZ {
impl Drop for CVec_TransactionOutputsZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_TransactionOutputsZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
impl CVec_BalanceZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning::chain::channelmonitor::Balance> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::channelmonitor::Balance] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::lightning::chain::channelmonitor::Balance>> for CVec_BalanceZ {
impl Drop for CVec_BalanceZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_BalanceZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::C2Tuple_BlockHashChannelMonitorZ, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZPtr { err }
};
Self {
/// The contents of CResult_NoneLightningErrorZ
pub union CResult_NoneLightningErrorZPtr {
/// Note that this value is always NULL, as there are no contents in the OK variant
- pub result: *mut std::ffi::c_void,
+ pub result: *mut core::ffi::c_void,
/// A pointer to the contents in the error state.
/// Reading from this pointer when `result_ok` is set is undefined.
pub err: *mut crate::lightning::ln::msgs::LightningError,
pub extern "C" fn CResult_NoneLightningErrorZ_ok() -> CResult_NoneLightningErrorZ {
CResult_NoneLightningErrorZ {
contents: CResult_NoneLightningErrorZPtr {
- result: std::ptr::null_mut(),
+ result: core::ptr::null_mut(),
},
result_ok: true,
}
fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::msgs::LightningError>) -> Self {
let contents = if o.result_ok {
let _ = unsafe { Box::from_raw(o.contents.result) };
- o.contents.result = std::ptr::null_mut();
- CResult_NoneLightningErrorZPtr { result: std::ptr::null_mut() }
+ o.contents.result = core::ptr::null_mut();
+ CResult_NoneLightningErrorZPtr { result: core::ptr::null_mut() }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_NoneLightningErrorZPtr { err }
};
Self {
fn clone(&self) -> Self {
if self.result_ok {
Self { result_ok: true, contents: CResult_NoneLightningErrorZPtr {
- result: std::ptr::null_mut()
+ result: core::ptr::null_mut()
} }
} else {
Self { result_ok: false, contents: CResult_NoneLightningErrorZPtr {
impl CVec_C2Tuple_PublicKeyTypeZZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::derived::C2Tuple_PublicKeyTypeZ> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C2Tuple_PublicKeyTypeZ] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::c_types::derived::C2Tuple_PublicKeyTypeZ>> for CVec_C2Tuple_PublicKeyTypeZZ {
impl Drop for CVec_C2Tuple_PublicKeyTypeZZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
#[repr(C)]
fn from(mut o: crate::c_types::CResultTempl<bool, crate::lightning::ln::msgs::LightningError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_boolLightningErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_boolLightningErrorZPtr { err }
};
Self {
impl CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::c_types::derived::C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ>> for CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
impl Drop for CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
impl CVec_NodeAnnouncementZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning::ln::msgs::NodeAnnouncement> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::NodeAnnouncement] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::lightning::ln::msgs::NodeAnnouncement>> for CVec_NodeAnnouncementZ {
impl Drop for CVec_NodeAnnouncementZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_NodeAnnouncementZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
impl CVec_PublicKeyZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::c_types::PublicKey> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::c_types::PublicKey] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::c_types::PublicKey>> for CVec_PublicKeyZ {
impl Drop for CVec_PublicKeyZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_PublicKeyZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::CVec_u8Z, crate::lightning::ln::peer_handler::PeerHandleError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_CVec_u8ZPeerHandleErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_CVec_u8ZPeerHandleErrorZPtr { err }
};
Self {
/// The contents of CResult_NonePeerHandleErrorZ
pub union CResult_NonePeerHandleErrorZPtr {
/// Note that this value is always NULL, as there are no contents in the OK variant
- pub result: *mut std::ffi::c_void,
+ pub result: *mut core::ffi::c_void,
/// A pointer to the contents in the error state.
/// Reading from this pointer when `result_ok` is set is undefined.
pub err: *mut crate::lightning::ln::peer_handler::PeerHandleError,
pub extern "C" fn CResult_NonePeerHandleErrorZ_ok() -> CResult_NonePeerHandleErrorZ {
CResult_NonePeerHandleErrorZ {
contents: CResult_NonePeerHandleErrorZPtr {
- result: std::ptr::null_mut(),
+ result: core::ptr::null_mut(),
},
result_ok: true,
}
fn from(mut o: crate::c_types::CResultTempl<(), crate::lightning::ln::peer_handler::PeerHandleError>) -> Self {
let contents = if o.result_ok {
let _ = unsafe { Box::from_raw(o.contents.result) };
- o.contents.result = std::ptr::null_mut();
- CResult_NonePeerHandleErrorZPtr { result: std::ptr::null_mut() }
+ o.contents.result = core::ptr::null_mut();
+ CResult_NonePeerHandleErrorZPtr { result: core::ptr::null_mut() }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_NonePeerHandleErrorZPtr { err }
};
Self {
fn clone(&self) -> Self {
if self.result_ok {
Self { result_ok: true, contents: CResult_NonePeerHandleErrorZPtr {
- result: std::ptr::null_mut()
+ result: core::ptr::null_mut()
} }
} else {
Self { result_ok: false, contents: CResult_NonePeerHandleErrorZPtr {
fn from(mut o: crate::c_types::CResultTempl<bool, crate::lightning::ln::peer_handler::PeerHandleError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_boolPeerHandleErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_boolPeerHandleErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::routing::network_graph::NodeId, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_NodeIdDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_NodeIdDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::c_types::derived::COption_NetworkUpdateZ, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_COption_NetworkUpdateZDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_COption_NetworkUpdateZDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::routing::network_graph::DirectionalChannelInfo, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_DirectionalChannelInfoDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_DirectionalChannelInfoDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::routing::network_graph::ChannelInfo, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ChannelInfoDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ChannelInfoDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::routing::network_graph::RoutingFees, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_RoutingFeesDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_RoutingFeesDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::routing::network_graph::NodeAnnouncementInfo, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_NodeAnnouncementInfoDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_NodeAnnouncementInfoDecodeErrorZPtr { err }
};
Self {
impl CVec_u64Z {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<u64> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[u64] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<u64>> for CVec_u64Z {
impl Drop for CVec_u64Z {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_u64Z {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::routing::network_graph::NodeInfo, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_NodeInfoDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_NodeInfoDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::routing::network_graph::NetworkGraph, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_NetworkGraphDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_NetworkGraphDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::NetAddress, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_NetAddressDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_NetAddressDecodeErrorZPtr { err }
};
Self {
impl CVec_UpdateAddHTLCZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning::ln::msgs::UpdateAddHTLC> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateAddHTLC] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::lightning::ln::msgs::UpdateAddHTLC>> for CVec_UpdateAddHTLCZ {
impl Drop for CVec_UpdateAddHTLCZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_UpdateAddHTLCZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
impl CVec_UpdateFulfillHTLCZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning::ln::msgs::UpdateFulfillHTLC> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFulfillHTLC] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::lightning::ln::msgs::UpdateFulfillHTLC>> for CVec_UpdateFulfillHTLCZ {
impl Drop for CVec_UpdateFulfillHTLCZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_UpdateFulfillHTLCZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
impl CVec_UpdateFailHTLCZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning::ln::msgs::UpdateFailHTLC> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFailHTLC] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::lightning::ln::msgs::UpdateFailHTLC>> for CVec_UpdateFailHTLCZ {
impl Drop for CVec_UpdateFailHTLCZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_UpdateFailHTLCZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
impl CVec_UpdateFailMalformedHTLCZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning::ln::msgs::UpdateFailMalformedHTLC> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::ln::msgs::UpdateFailMalformedHTLC] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::lightning::ln::msgs::UpdateFailMalformedHTLC>> for CVec_UpdateFailMalformedHTLCZ {
impl Drop for CVec_UpdateFailMalformedHTLCZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_UpdateFailMalformedHTLCZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::AcceptChannel, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_AcceptChannelDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_AcceptChannelDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::AnnouncementSignatures, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_AnnouncementSignaturesDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_AnnouncementSignaturesDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::ChannelReestablish, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ChannelReestablishDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ChannelReestablishDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::ClosingSigned, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ClosingSignedDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ClosingSignedDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::ClosingSignedFeeRange, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ClosingSignedFeeRangeDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ClosingSignedFeeRangeDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::CommitmentSigned, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_CommitmentSignedDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_CommitmentSignedDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::FundingCreated, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_FundingCreatedDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_FundingCreatedDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::FundingSigned, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_FundingSignedDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_FundingSignedDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::FundingLocked, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_FundingLockedDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_FundingLockedDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::Init, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_InitDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_InitDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::OpenChannel, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_OpenChannelDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_OpenChannelDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::RevokeAndACK, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_RevokeAndACKDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_RevokeAndACKDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::Shutdown, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ShutdownDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ShutdownDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::UpdateFailHTLC, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_UpdateFailHTLCDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_UpdateFailHTLCDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::UpdateFailMalformedHTLC, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_UpdateFailMalformedHTLCDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::UpdateFee, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_UpdateFeeDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_UpdateFeeDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::UpdateFulfillHTLC, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_UpdateFulfillHTLCDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_UpdateFulfillHTLCDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::UpdateAddHTLC, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_UpdateAddHTLCDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_UpdateAddHTLCDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::Ping, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_PingDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_PingDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::Pong, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_PongDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_PongDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::UnsignedChannelAnnouncement, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_UnsignedChannelAnnouncementDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::ChannelAnnouncement, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ChannelAnnouncementDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ChannelAnnouncementDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::UnsignedChannelUpdate, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_UnsignedChannelUpdateDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_UnsignedChannelUpdateDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::ChannelUpdate, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ChannelUpdateDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ChannelUpdateDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::ErrorMessage, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ErrorMessageDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ErrorMessageDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::UnsignedNodeAnnouncement, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_UnsignedNodeAnnouncementDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::NodeAnnouncement, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_NodeAnnouncementDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_NodeAnnouncementDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::QueryShortChannelIds, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_QueryShortChannelIdsDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_QueryShortChannelIdsDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::ReplyShortChannelIdsEnd, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ReplyShortChannelIdsEndDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::QueryChannelRange, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_QueryChannelRangeDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_QueryChannelRangeDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::ReplyChannelRange, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_ReplyChannelRangeDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_ReplyChannelRangeDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::ln::msgs::GossipTimestampFilter, crate::lightning::ln::msgs::DecodeError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_GossipTimestampFilterDecodeErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_GossipTimestampFilterDecodeErrorZPtr { err }
};
Self {
fn from(mut o: crate::c_types::CResultTempl<crate::lightning_invoice::Invoice, crate::lightning_invoice::SignOrCreationError>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_InvoiceSignOrCreationErrorZPtr { result }
} else {
let err = unsafe { o.contents.err };
- unsafe { o.contents.err = std::ptr::null_mut(); }
+ unsafe { o.contents.err = core::ptr::null_mut(); }
CResult_InvoiceSignOrCreationErrorZPtr { err }
};
Self {
/// Reading from this pointer when `result_ok` is not set is undefined.
pub result: *mut crate::lightning::chain::chainmonitor::LockedChannelMonitor,
/// Note that this value is always NULL, as there are no contents in the Err variant
- pub err: *mut std::ffi::c_void,
+ pub err: *mut core::ffi::c_void,
}
#[repr(C)]
/// A CResult_LockedChannelMonitorNoneZ represents the result of a fallible operation,
pub extern "C" fn CResult_LockedChannelMonitorNoneZ_err() -> CResult_LockedChannelMonitorNoneZ {
CResult_LockedChannelMonitorNoneZ {
contents: CResult_LockedChannelMonitorNoneZPtr {
- err: std::ptr::null_mut(),
+ err: core::ptr::null_mut(),
},
result_ok: false,
}
fn from(mut o: crate::c_types::CResultTempl<crate::lightning::chain::chainmonitor::LockedChannelMonitor, ()>) -> Self {
let contents = if o.result_ok {
let result = unsafe { o.contents.result };
- unsafe { o.contents.result = std::ptr::null_mut() };
+ unsafe { o.contents.result = core::ptr::null_mut() };
CResult_LockedChannelMonitorNoneZPtr { result }
} else {
let _ = unsafe { Box::from_raw(o.contents.err) };
- o.contents.err = std::ptr::null_mut();
- CResult_LockedChannelMonitorNoneZPtr { err: std::ptr::null_mut() }
+ o.contents.err = core::ptr::null_mut();
+ CResult_LockedChannelMonitorNoneZPtr { err: core::ptr::null_mut() }
};
Self {
contents,
impl CVec_OutPointZ {
#[allow(unused)] pub(crate) fn into_rust(&mut self) -> Vec<crate::lightning::chain::transaction::OutPoint> {
if self.datalen == 0 { return Vec::new(); }
- let ret = unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
- self.data = std::ptr::null_mut();
+ let ret = unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) }.into();
+ self.data = core::ptr::null_mut();
self.datalen = 0;
ret
}
#[allow(unused)] pub(crate) fn as_slice(&self) -> &[crate::lightning::chain::transaction::OutPoint] {
- unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) }
}
}
impl From<Vec<crate::lightning::chain::transaction::OutPoint>> for CVec_OutPointZ {
impl Drop for CVec_OutPointZ {
fn drop(&mut self) {
if self.datalen == 0 { return; }
- unsafe { Box::from_raw(std::slice::from_raw_parts_mut(self.data, self.datalen)) };
+ unsafe { Box::from_raw(core::slice::from_raw_parts_mut(self.data, self.datalen)) };
}
}
impl Clone for CVec_OutPointZ {
fn clone(&self) -> Self {
let mut res = Vec::new();
if self.datalen == 0 { return Self::from(res); }
- res.extend_from_slice(unsafe { std::slice::from_raw_parts_mut(self.data, self.datalen) });
+ res.extend_from_slice(unsafe { core::slice::from_raw_parts_mut(self.data, self.datalen) });
Self::from(res)
}
}
use bitcoin::secp256k1::recovery::RecoverableSignature as SecpRecoverableSignature;
use bitcoin::bech32;
-use std::convert::TryInto; // Bindings need at least rustc 1.34
+use core::convert::TryInto; // Bindings need at least rustc 1.34
use core::ffi::c_void;
-use std::io::{Cursor, Read}; // TODO: We should use core2 here when we support no_std
+
+#[cfg(feature = "std")]
+pub(crate) use std::io::{self, Cursor, Read};
+#[cfg(feature = "no-std")]
+pub(crate) use core2::io::{self, Cursor, Read};
+#[cfg(feature = "no-std")]
+use alloc::{boxed::Box, vec::Vec, string::String};
#[repr(C)]
/// A dummy struct of which an instance must never exist.
Other,
UnexpectedEof,
}
+#[cfg(feature = "std")]
impl IOError {
pub(crate) fn from_rust(err: std::io::Error) -> Self {
match err.kind() {
}
pub(crate) fn into_bitcoin(&self) -> BitcoinTransaction {
if self.datalen == 0 { panic!("0-length buffer can never represent a valid Transaction"); }
- ::bitcoin::consensus::encode::deserialize(unsafe { std::slice::from_raw_parts(self.data, self.datalen) }).unwrap()
+ ::bitcoin::consensus::encode::deserialize(unsafe { core::slice::from_raw_parts(self.data, self.datalen) }).unwrap()
}
pub(crate) fn from_bitcoin(btc: &BitcoinTransaction) -> Self {
let vec = ::bitcoin::consensus::encode::serialize(btc);
}
impl Clone for Transaction {
fn clone(&self) -> Self {
- let sl = unsafe { std::slice::from_raw_parts(self.data, self.datalen) };
+ let sl = unsafe { core::slice::from_raw_parts(self.data, self.datalen) };
let mut v = Vec::new();
v.extend_from_slice(&sl);
Self::from_vec(v)
}
pub(crate) fn to_slice(&self) -> &[u8] {
if self.datalen == 0 { return &[]; }
- unsafe { std::slice::from_raw_parts(self.data, self.datalen) }
+ unsafe { core::slice::from_raw_parts(self.data, self.datalen) }
}
pub(crate) fn to_reader<'a>(&'a self) -> Cursor<&'a [u8]> {
let sl = self.to_slice();
pub(crate) struct VecWriter(pub Vec<u8>);
impl lightning::util::ser::Writer for VecWriter {
- fn write_all(&mut self, buf: &[u8]) -> Result<(), ::std::io::Error> {
+ fn write_all(&mut self, buf: &[u8]) -> Result<(), io::Error> {
self.0.extend_from_slice(buf);
Ok(())
}
impl Str {
pub(crate) fn into_str(&self) -> &'static str {
if self.len == 0 { return ""; }
- std::str::from_utf8(unsafe { std::slice::from_raw_parts(self.chars, self.len) }).unwrap()
+ core::str::from_utf8(unsafe { core::slice::from_raw_parts(self.chars, self.len) }).unwrap()
}
pub(crate) fn into_string(mut self) -> String {
let bytes = if self.len == 0 {
Vec::new()
} else if self.chars_is_owned {
let ret = unsafe {
- Box::from_raw(std::slice::from_raw_parts_mut(unsafe { self.chars as *mut u8 }, self.len))
+ Box::from_raw(core::slice::from_raw_parts_mut(unsafe { self.chars as *mut u8 }, self.len))
}.into();
self.chars_is_owned = false;
ret
} else {
let mut ret = Vec::with_capacity(self.len);
- ret.extend_from_slice(unsafe { std::slice::from_raw_parts(self.chars, self.len) });
+ ret.extend_from_slice(unsafe { core::slice::from_raw_parts(self.chars, self.len) });
ret
};
String::from_utf8(bytes).unwrap()
impl<T> TakePointer<*const T> for *const T {
fn take_ptr(&mut self) -> *const T {
let ret = *self;
- *self = std::ptr::null();
+ *self = core::ptr::null();
ret
}
}
impl<T> TakePointer<*mut T> for *mut T {
fn take_ptr(&mut self) -> *mut T {
let ret = *self;
- *self = std::ptr::null_mut();
+ *self = core::ptr::null_mut();
ret
}
}
pub(crate) mod ObjOps {
+ #[cfg(feature = "no-std")]
+ use alloc::boxed::Box;
+
#[inline]
#[must_use = "returns new dangling pointer"]
pub(crate) fn heap_alloc<T>(obj: T) -> *mut T {
Self { ptr: Box::into_raw(Box::new(o)) }
}
pub(crate) fn null() -> Self {
- Self { ptr: std::ptr::null_mut() }
+ Self { ptr: core::ptr::null_mut() }
}
}
impl<T> Drop for SmartPtr<T> {
fn drop(&mut self) {
- if self.ptr != std::ptr::null_mut() {
+ if self.ptr != core::ptr::null_mut() {
unsafe { Box::from_raw(self.ptr); }
}
}
}
-impl<T> std::ops::Deref for SmartPtr<T> {
+impl<T> core::ops::Deref for SmartPtr<T> {
type Target = *mut T;
fn deref(&self) -> &*mut T {
&self.ptr
#![allow(unused_parens)]
#![allow(unused_unsafe)]
#![allow(unused_braces)]
+#![cfg_attr(not(feature = "std"), no_std)]
+#[cfg(not(any(feature = "std", feature = "no-std")))]
+compile_error!("at least one of the `std` or `no-std` features must be enabled");
+extern crate alloc;
pub mod version;
pub mod c_types;
pub mod bitcoin;
//! Includes traits for monitoring and receiving notifications of new blocks and block
//! disconnections, transaction broadcasting, and feerate information requests.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
/// An interface to send a transaction to the Bitcoin network.
#[repr(C)]
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for BroadcasterInterface {
+impl core::ops::Deref for BroadcasterInterface {
type Target = Self;
fn deref(&self) -> &Self {
self
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for FeeEstimator {
+impl core::ops::Deref for FeeEstimator {
type Target = Self;
fn deref(&self) -> &Self {
self
//! events. The remote server would make use of [`ChainMonitor`] for block processing and for
//! servicing [`ChannelMonitor`] updates from the client.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
use lightning::chain::chainmonitor::MonitorUpdateId as nativeMonitorUpdateIdImport;
pub(crate) fn take_inner(mut self) -> *mut nativeMonitorUpdateId {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for MonitorUpdateId {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeMonitorUpdateId>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeMonitorUpdateId>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
#[no_mangle]
pub extern "C" fn MonitorUpdateId_hash(o: &MonitorUpdateId) -> u64 {
if o.inner.is_null() { return 0; }
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
/// Checks if two MonitorUpdateIds contain equal inner contents.
/// This ignores pointers and is_owned flags and looks at the values in fields.
local_ret
}
fn update_persisted_channel(&self, mut channel_id: lightning::chain::transaction::OutPoint, mut update: &Option<lightning::chain::channelmonitor::ChannelMonitorUpdate>, mut data: &lightning::chain::channelmonitor::ChannelMonitor<crate::lightning::chain::keysinterface::Sign>, mut update_id: lightning::chain::chainmonitor::MonitorUpdateId) -> Result<(), lightning::chain::ChannelMonitorUpdateErr> {
- let mut local_update = &crate::lightning::chain::channelmonitor::ChannelMonitorUpdate { inner: unsafe { (if update.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (update.as_ref().unwrap()) }) } as *const lightning::chain::channelmonitor::ChannelMonitorUpdate<>) as *mut _ }, is_owned: false };
+ let mut local_update = &crate::lightning::chain::channelmonitor::ChannelMonitorUpdate { inner: unsafe { (if update.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (update.as_ref().unwrap()) }) } as *const lightning::chain::channelmonitor::ChannelMonitorUpdate<>) as *mut _ }, is_owned: false };
let mut ret = (self.update_persisted_channel)(self.this_arg, crate::lightning::chain::transaction::OutPoint { inner: ObjOps::heap_alloc(channel_id), is_owned: true }, local_update, &crate::lightning::chain::channelmonitor::ChannelMonitor { inner: unsafe { ObjOps::nonnull_ptr_to_inner((data as *const lightning::chain::channelmonitor::ChannelMonitor<_, >) as *mut _) }, is_owned: false }, crate::lightning::chain::chainmonitor::MonitorUpdateId { inner: ObjOps::heap_alloc(update_id), is_owned: true });
let mut local_ret = match ret.result_ok { true => Ok( { () /*(*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ }), false => Err( { (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).into_native() })};
local_ret
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for Persist {
+impl core::ops::Deref for Persist {
type Target = Self;
fn deref(&self) -> &Self {
self
pub(crate) fn take_inner(mut self) -> *mut nativeLockedChannelMonitor {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
pub(crate) fn take_inner(mut self) -> *mut nativeChainMonitor {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
let mut rust_obj = ChainMonitor { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = ChainMonitor_as_Listen(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(ChainMonitor_free_void);
ret
}
let mut rust_obj = ChainMonitor { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = ChainMonitor_as_Confirm(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(ChainMonitor_free_void);
ret
}
let mut rust_obj = ChainMonitor { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = ChainMonitor_as_Watch(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(ChainMonitor_free_void);
ret
}
let mut rust_obj = ChainMonitor { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = ChainMonitor_as_EventsProvider(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(ChainMonitor_free_void);
ret
}
//! security-domain-separated system design, you should consider having multiple paths for
//! ChannelMonitors to get out of the HSM and onto monitoring devices.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
use lightning::chain::channelmonitor::ChannelMonitorUpdate as nativeChannelMonitorUpdateImport;
pub(crate) fn take_inner(mut self) -> *mut nativeChannelMonitorUpdate {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ChannelMonitorUpdate {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeChannelMonitorUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeChannelMonitorUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeHTLCUpdate {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for HTLCUpdate {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeHTLCUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeHTLCUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeChannelMonitor {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
//! spendable on-chain outputs which the user owns and is responsible for using just as any other
//! on-chain output which is theirs.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
use lightning::chain::keysinterface::DelayedPaymentOutputDescriptor as nativeDelayedPaymentOutputDescriptorImport;
pub(crate) fn take_inner(mut self) -> *mut nativeDelayedPaymentOutputDescriptor {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for DelayedPaymentOutputDescriptor {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeDelayedPaymentOutputDescriptor>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeDelayedPaymentOutputDescriptor>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeStaticPaymentOutputDescriptor {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for StaticPaymentOutputDescriptor {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeStaticPaymentOutputDescriptor>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeStaticPaymentOutputDescriptor>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for BaseSign {
+impl core::ops::Deref for BaseSign {
type Target = Self;
fn deref(&self) -> &Self {
self
}
}
impl lightning::util::ser::Writeable for Sign {
- fn write<W: lightning::util::ser::Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {
+ fn write<W: lightning::util::ser::Writer>(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> {
let vec = (self.write)(self.this_arg);
w.write_all(vec.as_slice())
}
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for Sign {
+impl core::ops::Deref for Sign {
type Target = Self;
fn deref(&self) -> &Self {
self
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for KeysInterface {
+impl core::ops::Deref for KeysInterface {
type Target = Self;
fn deref(&self) -> &Self {
self
pub(crate) fn take_inner(mut self) -> *mut nativeInMemorySigner {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for InMemorySigner {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeInMemorySigner>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeInMemorySigner>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = InMemorySigner_as_BaseSign(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(InMemorySigner_free_void);
ret
}
release_commitment_secret: InMemorySigner_BaseSign_release_commitment_secret,
validate_holder_commitment: InMemorySigner_BaseSign_validate_holder_commitment,
- pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: std::ptr::null_mut(), is_owned: true },
+ pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true },
set_pubkeys: Some(InMemorySigner_BaseSign_set_pubkeys),
channel_keys_id: InMemorySigner_BaseSign_channel_keys_id,
sign_counterparty_commitment: InMemorySigner_BaseSign_sign_counterparty_commitment,
let mut rust_obj = InMemorySigner { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = InMemorySigner_as_Sign(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(InMemorySigner_free_void);
ret
}
release_commitment_secret: InMemorySigner_BaseSign_release_commitment_secret,
validate_holder_commitment: InMemorySigner_BaseSign_validate_holder_commitment,
- pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: std::ptr::null_mut(), is_owned: true },
+ pubkeys: crate::lightning::ln::chan_utils::ChannelPublicKeys { inner: core::ptr::null_mut(), is_owned: true },
set_pubkeys: Some(InMemorySigner_BaseSign_set_pubkeys),
channel_keys_id: InMemorySigner_BaseSign_channel_keys_id,
sign_counterparty_commitment: InMemorySigner_BaseSign_sign_counterparty_commitment,
pub(crate) fn take_inner(mut self) -> *mut nativeKeysManager {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
let mut rust_obj = KeysManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = KeysManager_as_KeysInterface(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(KeysManager_free_void);
ret
}
//! Structs and traits which allow other parts of rust-lightning to interact with the blockchain.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
pub mod chaininterface;
pub mod chainmonitor;
pub mod keysinterface;
mod onchaintx {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
mod package {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
pub(crate) fn take_inner(mut self) -> *mut nativeBestBlock {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for BestBlock {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeBestBlock>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeBestBlock>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for Access {
+impl core::ops::Deref for Access {
type Target = Self;
fn deref(&self) -> &Self {
self
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for Listen {
+impl core::ops::Deref for Listen {
type Target = Self;
fn deref(&self) -> &Self {
self
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for Confirm {
+impl core::ops::Deref for Confirm {
type Target = Self;
fn deref(&self) -> &Self {
self
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for Watch {
+impl core::ops::Deref for Watch {
type Target = Self;
fn deref(&self) -> &Self {
self
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for Filter {
+impl core::ops::Deref for Filter {
type Target = Self;
fn deref(&self) -> &Self {
self
pub(crate) fn take_inner(mut self) -> *mut nativeWatchedOutput {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for WatchedOutput {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeWatchedOutput>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeWatchedOutput>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
#[no_mangle]
pub extern "C" fn WatchedOutput_hash(o: &WatchedOutput) -> u64 {
if o.inner.is_null() { return 0; }
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
//! Types describing on-chain transactions.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
use lightning::chain::transaction::OutPoint as nativeOutPointImport;
pub(crate) fn take_inner(mut self) -> *mut nativeOutPoint {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for OutPoint {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeOutPoint>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeOutPoint>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
#[no_mangle]
pub extern "C" fn OutPoint_hash(o: &OutPoint) -> u64 {
if o.inner.is_null() { return 0; }
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
/// Convert an `OutPoint` to a lightning channel id.
#[must_use]
//! Various utilities for building scripts and deriving keys related to channels. These are
//! largely of interest for those implementing chain::keysinterface::Sign message signing by hand.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
/// Gets the weight for an HTLC-Success transaction.
#[no_mangle]
pub(crate) fn take_inner(mut self) -> *mut nativeTxCreationKeys {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for TxCreationKeys {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeTxCreationKeys>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeTxCreationKeys>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeChannelPublicKeys {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ChannelPublicKeys {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeChannelPublicKeys>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeChannelPublicKeys>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeHTLCOutputInCommitment {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for HTLCOutputInCommitment {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeHTLCOutputInCommitment>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeHTLCOutputInCommitment>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeChannelTransactionParameters {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
#[no_mangle]
pub extern "C" fn ChannelTransactionParameters_get_counterparty_parameters(this_ptr: &ChannelTransactionParameters) -> crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters {
let mut inner_val = &mut this_ptr.get_native_mut_ref().counterparty_parameters;
- let mut local_inner_val = crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::chan_utils::CounterpartyChannelTransactionParameters<>) as *mut _ }, is_owned: false };
+ let mut local_inner_val = crate::lightning::ln::chan_utils::CounterpartyChannelTransactionParameters { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::chan_utils::CounterpartyChannelTransactionParameters<>) as *mut _ }, is_owned: false };
local_inner_val
}
/// The late-bound counterparty channel transaction parameters.
#[no_mangle]
pub extern "C" fn ChannelTransactionParameters_get_funding_outpoint(this_ptr: &ChannelTransactionParameters) -> crate::lightning::chain::transaction::OutPoint {
let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_outpoint;
- let mut local_inner_val = crate::lightning::chain::transaction::OutPoint { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::chain::transaction::OutPoint<>) as *mut _ }, is_owned: false };
+ let mut local_inner_val = crate::lightning::chain::transaction::OutPoint { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::chain::transaction::OutPoint<>) as *mut _ }, is_owned: false };
local_inner_val
}
/// The late-bound funding outpoint
impl Clone for ChannelTransactionParameters {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeChannelTransactionParameters>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeChannelTransactionParameters>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeCounterpartyChannelTransactionParameters {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for CounterpartyChannelTransactionParameters {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeCounterpartyChannelTransactionParameters>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeCounterpartyChannelTransactionParameters>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeDirectedChannelTransactionParameters {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
pub(crate) fn take_inner(mut self) -> *mut nativeHolderCommitmentTransaction {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for HolderCommitmentTransaction {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeHolderCommitmentTransaction>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeHolderCommitmentTransaction>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeBuiltCommitmentTransaction {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for BuiltCommitmentTransaction {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeBuiltCommitmentTransaction>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeBuiltCommitmentTransaction>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeClosingTransaction {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ClosingTransaction {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeClosingTransaction>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeClosingTransaction>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
#[no_mangle]
pub extern "C" fn ClosingTransaction_hash(o: &ClosingTransaction) -> u64 {
if o.inner.is_null() { return 0; }
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
/// Construct an object of the class
#[must_use]
pub(crate) fn take_inner(mut self) -> *mut nativeTrustedClosingTransaction {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentTransaction {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for CommitmentTransaction {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeCommitmentTransaction>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeCommitmentTransaction>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeTrustedCommitmentTransaction {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
//! imply it needs to fail HTLCs/payments/channels it manages).
//!
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
mod inbound_payment {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
pub(crate) fn take_inner(mut self) -> *mut nativeChannelManager {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
pub(crate) fn take_inner(mut self) -> *mut nativeChainParameters {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ChainParameters {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeChainParameters>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeChainParameters>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeCounterpartyForwardingInfo {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for CounterpartyForwardingInfo {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeCounterpartyForwardingInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeChannelCounterparty {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
#[no_mangle]
pub extern "C" fn ChannelCounterparty_get_forwarding_info(this_ptr: &ChannelCounterparty) -> crate::lightning::ln::channelmanager::CounterpartyForwardingInfo {
let mut inner_val = &mut this_ptr.get_native_mut_ref().forwarding_info;
- let mut local_inner_val = crate::lightning::ln::channelmanager::CounterpartyForwardingInfo { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::channelmanager::CounterpartyForwardingInfo<>) as *mut _ }, is_owned: false };
+ let mut local_inner_val = crate::lightning::ln::channelmanager::CounterpartyForwardingInfo { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::channelmanager::CounterpartyForwardingInfo<>) as *mut _ }, is_owned: false };
local_inner_val
}
/// Information on the fees and requirements that the counterparty requires when forwarding
impl Clone for ChannelCounterparty {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeChannelCounterparty>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeChannelCounterparty>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeChannelDetails {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
#[no_mangle]
pub extern "C" fn ChannelDetails_get_funding_txo(this_ptr: &ChannelDetails) -> crate::lightning::chain::transaction::OutPoint {
let mut inner_val = &mut this_ptr.get_native_mut_ref().funding_txo;
- let mut local_inner_val = crate::lightning::chain::transaction::OutPoint { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::chain::transaction::OutPoint<>) as *mut _ }, is_owned: false };
+ let mut local_inner_val = crate::lightning::chain::transaction::OutPoint { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::chain::transaction::OutPoint<>) as *mut _ }, is_owned: false };
local_inner_val
}
/// The Channel's funding transaction output, if we've negotiated the funding transaction with
impl Clone for ChannelDetails {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeChannelDetails>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeChannelDetails>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
let mut results_nonref = (*results).clone();
let mut local_results_nonref = Vec::new(); for mut item in results_nonref.drain(..) { local_results_nonref.push( { let mut local_results_nonref_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_results_nonref_0 }); };
let mut failed_paths_retry_nonref = (*failed_paths_retry).clone();
- let mut local_failed_paths_retry_nonref = crate::lightning::routing::router::RouteParameters { inner: if failed_paths_retry_nonref.is_none() { std::ptr::null_mut() } else { { ObjOps::heap_alloc((failed_paths_retry_nonref.unwrap())) } }, is_owned: true };
+ let mut local_failed_paths_retry_nonref = crate::lightning::routing::router::RouteParameters { inner: if failed_paths_retry_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((failed_paths_retry_nonref.unwrap())) } }, is_owned: true };
let mut payment_id_nonref = (*payment_id).clone();
PaymentSendFailure::PartialFailure {
results: local_results_nonref.into(),
},
nativePaymentSendFailure::PartialFailure {mut results, mut failed_paths_retry, mut payment_id, } => {
let mut local_results = Vec::new(); for mut item in results.drain(..) { local_results.push( { let mut local_results_0 = match item { Ok(mut o) => crate::c_types::CResultTempl::ok( { () /*o*/ }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::util::errors::APIError::native_into(e) }).into() }; local_results_0 }); };
- let mut local_failed_paths_retry = crate::lightning::routing::router::RouteParameters { inner: if failed_paths_retry.is_none() { std::ptr::null_mut() } else { { ObjOps::heap_alloc((failed_paths_retry.unwrap())) } }, is_owned: true };
+ let mut local_failed_paths_retry = crate::lightning::routing::router::RouteParameters { inner: if failed_paths_retry.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((failed_paths_retry.unwrap())) } }, is_owned: true };
PaymentSendFailure::PartialFailure {
results: local_results.into(),
failed_paths_retry: local_failed_paths_retry,
let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = ChannelManager_as_MessageSendEventsProvider(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(ChannelManager_free_void);
ret
}
let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = ChannelManager_as_EventsProvider(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(ChannelManager_free_void);
ret
}
let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = ChannelManager_as_Listen(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(ChannelManager_free_void);
ret
}
let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = ChannelManager_as_Confirm(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(ChannelManager_free_void);
ret
}
#[must_use]
#[no_mangle]
pub extern "C" fn ChannelManager_await_persistable_update_timeout(this_arg: &ChannelManager, mut max_wait: u64) -> bool {
- let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.await_persistable_update_timeout(std::time::Duration::from_secs(max_wait));
+ let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.await_persistable_update_timeout(core::time::Duration::from_secs(max_wait));
ret
}
let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = ChannelManager_as_ChannelMessageHandler(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(ChannelManager_free_void);
ret
}
pub(crate) fn take_inner(mut self) -> *mut nativeChannelManagerReadArgs {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
//! [BOLT #9]: https://github.com/lightningnetwork/lightning-rfc/blob/master/09-features.md
//! [messages]: crate::ln::msgs
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
mod sealed {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
/// Checks if two InitFeaturess contain equal inner contents.
impl Clone for InitFeatures {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeInitFeatures>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeInitFeatures>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
impl Clone for NodeFeatures {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeNodeFeatures>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeNodeFeatures>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
impl Clone for ChannelFeatures {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeChannelFeatures>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeChannelFeatures>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
impl Clone for InvoiceFeatures {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeInvoiceFeatures>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeInvoiceFeatures>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
impl Clone for ChannelTypeFeatures {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeChannelTypeFeatures>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeChannelTypeFeatures>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeInitFeatures {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
pub(crate) fn take_inner(mut self) -> *mut nativeNodeFeatures {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
pub(crate) fn take_inner(mut self) -> *mut nativeChannelFeatures {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceFeatures {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
pub(crate) fn take_inner(mut self) -> *mut nativeChannelTypeFeatures {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
//! you want to learn things about the network topology (eg get a route for sending a payment),
//! call into your NetGraphMsgHandler.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
pub mod channelmanager;
pub mod msgs;
pub mod wire;
mod peer_channel_encryptor {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
mod channel {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
mod onion_utils {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
//! raw socket events into your non-internet-facing system and then send routing events back to
//! track the network on the less-secure system.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
use lightning::ln::msgs::DecodeError as nativeDecodeErrorImport;
pub(crate) fn take_inner(mut self) -> *mut nativeDecodeError {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for DecodeError {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeDecodeError>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeDecodeError>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeInit {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for Init {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeInit>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeInit>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeErrorMessage {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ErrorMessage {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeErrorMessage>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeErrorMessage>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativePing {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for Ping {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativePing>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativePing>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativePong {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for Pong {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativePong>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativePong>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeOpenChannel {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
#[no_mangle]
pub extern "C" fn OpenChannel_get_channel_type(this_ptr: &OpenChannel) -> crate::lightning::ln::features::ChannelTypeFeatures {
let mut inner_val = &mut this_ptr.get_native_mut_ref().channel_type;
- let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
+ let mut local_inner_val = crate::lightning::ln::features::ChannelTypeFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::ChannelTypeFeatures<>) as *mut _ }, is_owned: false };
local_inner_val
}
/// The channel type that this channel will represent. If none is set, we derive the channel
impl Clone for OpenChannel {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeOpenChannel>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeOpenChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeAcceptChannel {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for AcceptChannel {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeAcceptChannel>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeFundingCreated {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for FundingCreated {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeFundingCreated>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeFundingCreated>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeFundingSigned {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for FundingSigned {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeFundingSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeFundingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeFundingLocked {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for FundingLocked {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeFundingLocked>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeFundingLocked>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeShutdown {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for Shutdown {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeShutdown>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeShutdown>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeClosingSignedFeeRange {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ClosingSignedFeeRange {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeClosingSignedFeeRange>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeClosingSigned {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
#[no_mangle]
pub extern "C" fn ClosingSigned_get_fee_range(this_ptr: &ClosingSigned) -> crate::lightning::ln::msgs::ClosingSignedFeeRange {
let mut inner_val = &mut this_ptr.get_native_mut_ref().fee_range;
- let mut local_inner_val = crate::lightning::ln::msgs::ClosingSignedFeeRange { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::ClosingSignedFeeRange<>) as *mut _ }, is_owned: false };
+ let mut local_inner_val = crate::lightning::ln::msgs::ClosingSignedFeeRange { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::ClosingSignedFeeRange<>) as *mut _ }, is_owned: false };
local_inner_val
}
/// The minimum and maximum fees which the sender is willing to accept, provided only by new
impl Clone for ClosingSigned {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeClosingSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeClosingSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeUpdateAddHTLC {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for UpdateAddHTLC {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeUpdateAddHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFulfillHTLC {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for UpdateFulfillHTLC {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeUpdateFulfillHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailHTLC {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for UpdateFailHTLC {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeUpdateFailHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFailMalformedHTLC {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for UpdateFailMalformedHTLC {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeUpdateFailMalformedHTLC>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentSigned {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for CommitmentSigned {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeCommitmentSigned>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeRevokeAndACK {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for RevokeAndACK {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeRevokeAndACK>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeUpdateFee {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for UpdateFee {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeUpdateFee>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeUpdateFee>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeDataLossProtect {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for DataLossProtect {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeDataLossProtect>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeChannelReestablish {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ChannelReestablish {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeChannelReestablish>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeAnnouncementSignatures {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for AnnouncementSignatures {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeAnnouncementSignatures>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedNodeAnnouncement {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for UnsignedNodeAnnouncement {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeUnsignedNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncement {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for NodeAnnouncement {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeNodeAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelAnnouncement {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for UnsignedChannelAnnouncement {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeUnsignedChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeChannelAnnouncement {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ChannelAnnouncement {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeChannelAnnouncement>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeUnsignedChannelUpdate {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for UnsignedChannelUpdate {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeUnsignedChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeChannelUpdate {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ChannelUpdate {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeChannelUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeQueryChannelRange {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for QueryChannelRange {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeQueryChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeReplyChannelRange {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ReplyChannelRange {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeReplyChannelRange>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeQueryShortChannelIds {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for QueryShortChannelIds {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeQueryShortChannelIds>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeReplyShortChannelIdsEnd {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ReplyShortChannelIdsEnd {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeReplyShortChannelIdsEnd>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeGossipTimestampFilter {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for GossipTimestampFilter {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeGossipTimestampFilter>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
match native {
nativeErrorAction::DisconnectPeer {ref msg, } => {
let mut msg_nonref = (*msg).clone();
- let mut local_msg_nonref = crate::lightning::ln::msgs::ErrorMessage { inner: if msg_nonref.is_none() { std::ptr::null_mut() } else { { ObjOps::heap_alloc((msg_nonref.unwrap())) } }, is_owned: true };
+ let mut local_msg_nonref = crate::lightning::ln::msgs::ErrorMessage { inner: if msg_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((msg_nonref.unwrap())) } }, is_owned: true };
ErrorAction::DisconnectPeer {
msg: local_msg_nonref,
}
pub(crate) fn native_into(native: nativeErrorAction) -> Self {
match native {
nativeErrorAction::DisconnectPeer {mut msg, } => {
- let mut local_msg = crate::lightning::ln::msgs::ErrorMessage { inner: if msg.is_none() { std::ptr::null_mut() } else { { ObjOps::heap_alloc((msg.unwrap())) } }, is_owned: true };
+ let mut local_msg = crate::lightning::ln::msgs::ErrorMessage { inner: if msg.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((msg.unwrap())) } }, is_owned: true };
ErrorAction::DisconnectPeer {
msg: local_msg,
}
pub(crate) fn take_inner(mut self) -> *mut nativeLightningError {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for LightningError {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeLightningError>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeLightningError>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeCommitmentUpdate {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
#[no_mangle]
pub extern "C" fn CommitmentUpdate_get_update_fee(this_ptr: &CommitmentUpdate) -> crate::lightning::ln::msgs::UpdateFee {
let mut inner_val = &mut this_ptr.get_native_mut_ref().update_fee;
- let mut local_inner_val = crate::lightning::ln::msgs::UpdateFee { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::UpdateFee<>) as *mut _ }, is_owned: false };
+ let mut local_inner_val = crate::lightning::ln::msgs::UpdateFee { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::UpdateFee<>) as *mut _ }, is_owned: false };
local_inner_val
}
/// An update_fee message which should be sent
impl Clone for CommitmentUpdate {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeCommitmentUpdate>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for ChannelMessageHandler {
+impl core::ops::Deref for ChannelMessageHandler {
type Target = Self;
fn deref(&self) -> &Self {
self
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for RoutingMessageHandler {
+impl core::ops::Deref for RoutingMessageHandler {
type Target = Self;
fn deref(&self) -> &Self {
self
}
mod fuzzy_internal_msgs {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
#[no_mangle]
//! call into the provided message handlers (probably a ChannelManager and NetGraphmsgHandler) with messages
//! they should handle, and encoding/sending response messages.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
/// Handler for BOLT1-compliant messages.
#[repr(C)]
}
impl lightning::ln::wire::CustomMessageReader for CustomMessageHandler {
type CustomMessage = crate::lightning::ln::wire::Type;
- fn read<R:std::io::Read>(&self, mut message_type: u16, mut buffer: &mut R) -> Result<Option<crate::lightning::ln::wire::Type>, lightning::ln::msgs::DecodeError> {
+ fn read<R:crate::c_types::io::Read>(&self, mut message_type: u16, mut buffer: &mut R) -> Result<Option<crate::lightning::ln::wire::Type>, lightning::ln::msgs::DecodeError> {
let mut ret = (self.CustomMessageReader.read)(self.CustomMessageReader.this_arg, message_type, crate::c_types::u8slice::from_vec(&crate::c_types::reader_to_vec(buffer)));
let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = { /* (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ let ret_0_opt = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }); { } if ret_0_opt.is_none() { None } else { Some({ ret_0_opt.take() }) } }; local_ret_0 }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
local_ret
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for CustomMessageHandler {
+impl core::ops::Deref for CustomMessageHandler {
type Target = Self;
fn deref(&self) -> &Self {
self
pub(crate) fn take_inner(mut self) -> *mut nativeIgnoringMessageHandler {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
let mut rust_obj = IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(IgnoringMessageHandler_free_void);
ret
}
let mut rust_obj = IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = IgnoringMessageHandler_as_RoutingMessageHandler(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(IgnoringMessageHandler_free_void);
ret
}
#[must_use]
extern "C" fn IgnoringMessageHandler_RoutingMessageHandler_get_next_channel_announcements(this_arg: *const c_void, mut _starting_point: u64, mut _batch_amount: u8) -> crate::c_types::derived::CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
let mut ret = <nativeIgnoringMessageHandler as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_channel_announcements(unsafe { &mut *(this_arg as *mut nativeIgnoringMessageHandler) }, _starting_point, _batch_amount);
- let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item; let mut local_orig_ret_0_1 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_1.is_none() { std::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_1.unwrap())) } }, is_owned: true }; let mut local_orig_ret_0_2 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_2.is_none() { std::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_2.unwrap())) } }, is_owned: true }; let mut local_ret_0 = (crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, local_orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }); };
+ let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item; let mut local_orig_ret_0_1 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_1.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_1.unwrap())) } }, is_owned: true }; let mut local_orig_ret_0_2 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_2.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_2.unwrap())) } }, is_owned: true }; let mut local_ret_0 = (crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, local_orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }); };
local_ret.into()
}
#[must_use]
let mut rust_obj = IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = IgnoringMessageHandler_as_CustomMessageReader(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(IgnoringMessageHandler_free_void);
ret
}
let mut rust_obj = IgnoringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = IgnoringMessageHandler_as_CustomMessageHandler(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(IgnoringMessageHandler_free_void);
ret
}
pub(crate) fn take_inner(mut self) -> *mut nativeErroringMessageHandler {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
let mut rust_obj = ErroringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = ErroringMessageHandler_as_MessageSendEventsProvider(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(ErroringMessageHandler_free_void);
ret
}
let mut rust_obj = ErroringMessageHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = ErroringMessageHandler_as_ChannelMessageHandler(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(ErroringMessageHandler_free_void);
ret
}
pub(crate) fn take_inner(mut self) -> *mut nativeMessageHandler {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
free: Clone::clone(&orig.free),
}
}
-impl std::cmp::Eq for SocketDescriptor {}
-impl std::cmp::PartialEq for SocketDescriptor {
+impl core::cmp::Eq for SocketDescriptor {}
+impl core::cmp::PartialEq for SocketDescriptor {
fn eq(&self, o: &Self) -> bool { (self.eq)(self.this_arg, o) }
}
-impl std::hash::Hash for SocketDescriptor {
- fn hash<H: std::hash::Hasher>(&self, hasher: &mut H) { hasher.write_u64((self.hash)(self.this_arg)) }
+impl core::hash::Hash for SocketDescriptor {
+ fn hash<H: core::hash::Hasher>(&self, hasher: &mut H) { hasher.write_u64((self.hash)(self.this_arg)) }
}
#[no_mangle]
/// Creates a copy of a SocketDescriptor
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for SocketDescriptor {
+impl core::ops::Deref for SocketDescriptor {
type Target = Self;
fn deref(&self) -> &Self {
self
pub(crate) fn take_inner(mut self) -> *mut nativePeerHandleError {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for PeerHandleError {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativePeerHandleError>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativePeerHandleError>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativePeerManager {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
//! Abstractions for scripts used in the Lightning Network.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
use lightning::ln::script::ShutdownScript as nativeShutdownScriptImport;
pub(crate) fn take_inner(mut self) -> *mut nativeShutdownScript {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ShutdownScript {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeShutdownScript>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeShutdownScript>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeInvalidShutdownScript {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for InvalidShutdownScript {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeInvalidShutdownScript>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeInvalidShutdownScript>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
//!
//! [BOLT #1]: https://github.com/lightningnetwork/lightning-rfc/blob/master/01-messaging.md
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
/// Trait to be implemented by custom message (unrelated to the channel/gossip LN layers)
/// decoders.
use lightning::ln::wire::CustomMessageReader as rustCustomMessageReader;
impl rustCustomMessageReader for CustomMessageReader {
type CustomMessage = crate::lightning::ln::wire::Type;
- fn read<R:std::io::Read>(&self, mut message_type: u16, mut buffer: &mut R) -> Result<Option<crate::lightning::ln::wire::Type>, lightning::ln::msgs::DecodeError> {
+ fn read<R:crate::c_types::io::Read>(&self, mut message_type: u16, mut buffer: &mut R) -> Result<Option<crate::lightning::ln::wire::Type>, lightning::ln::msgs::DecodeError> {
let mut ret = (self.read)(self.this_arg, message_type, crate::c_types::u8slice::from_vec(&crate::c_types::reader_to_vec(buffer)));
let mut local_ret = match ret.result_ok { true => Ok( { let mut local_ret_0 = { /* (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) })*/ let ret_0_opt = (*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.result)) }); { } if ret_0_opt.is_none() { None } else { Some({ ret_0_opt.take() }) } }; local_ret_0 }), false => Err( { *unsafe { Box::from_raw((*unsafe { Box::from_raw(<*mut _>::take_ptr(&mut ret.contents.err)) }).take_inner()) } })};
local_ret
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for CustomMessageReader {
+impl core::ops::Deref for CustomMessageReader {
type Target = Self;
fn deref(&self) -> &Self {
self
}
mod encode {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
/// Defines a type identifier for sending messages over the wire.
}
}
impl lightning::util::ser::Writeable for Type {
- fn write<W: lightning::util::ser::Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {
+ fn write<W: lightning::util::ser::Writer>(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> {
let vec = (self.write)(self.this_arg);
w.write_all(vec.as_slice())
}
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for Type {
+impl core::ops::Deref for Type {
type Target = Self;
fn deref(&self) -> &Self {
self
//! generated/etc. This makes it a good candidate for tight integration into an existing wallet
//! instead of having a rather-separate lightning appendage to a wallet.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
pub mod util;
pub mod chain;
pub mod routing;
mod prelude {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
//! Structs and impls for receiving messages about the network and storing the topology live here.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
pub mod network_graph;
pub mod router;
//! The top-level network map tracking logic lives here.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
use lightning::routing::network_graph::NodeId as nativeNodeIdImport;
pub(crate) fn take_inner(mut self) -> *mut nativeNodeId {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for NodeId {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeNodeId>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeNodeId>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
#[no_mangle]
pub extern "C" fn NodeId_hash(o: &NodeId) -> u64 {
if o.inner.is_null() { return 0; }
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
#[no_mangle]
/// Serialize the NodeId object into a byte array which can be read by NodeId_read
pub(crate) fn take_inner(mut self) -> *mut nativeNetworkGraph {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for NetworkGraph {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeNetworkGraph>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeNetworkGraph>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeReadOnlyNetworkGraph {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
let mut rust_obj = NetGraphMsgHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = NetGraphMsgHandler_as_EventHandler(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(NetGraphMsgHandler_free_void);
ret
}
pub(crate) fn take_inner(mut self) -> *mut nativeNetGraphMsgHandler {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
let mut rust_obj = NetGraphMsgHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = NetGraphMsgHandler_as_RoutingMessageHandler(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(NetGraphMsgHandler_free_void);
ret
}
#[must_use]
extern "C" fn NetGraphMsgHandler_RoutingMessageHandler_get_next_channel_announcements(this_arg: *const c_void, mut starting_point: u64, mut batch_amount: u8) -> crate::c_types::derived::CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ {
let mut ret = <nativeNetGraphMsgHandler as lightning::ln::msgs::RoutingMessageHandler<>>::get_next_channel_announcements(unsafe { &mut *(this_arg as *mut nativeNetGraphMsgHandler) }, starting_point, batch_amount);
- let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item; let mut local_orig_ret_0_1 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_1.is_none() { std::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_1.unwrap())) } }, is_owned: true }; let mut local_orig_ret_0_2 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_2.is_none() { std::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_2.unwrap())) } }, is_owned: true }; let mut local_ret_0 = (crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, local_orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }); };
+ let mut local_ret = Vec::new(); for mut item in ret.drain(..) { local_ret.push( { let (mut orig_ret_0_0, mut orig_ret_0_1, mut orig_ret_0_2) = item; let mut local_orig_ret_0_1 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_1.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_1.unwrap())) } }, is_owned: true }; let mut local_orig_ret_0_2 = crate::lightning::ln::msgs::ChannelUpdate { inner: if orig_ret_0_2.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((orig_ret_0_2.unwrap())) } }, is_owned: true }; let mut local_ret_0 = (crate::lightning::ln::msgs::ChannelAnnouncement { inner: ObjOps::heap_alloc(orig_ret_0_0), is_owned: true }, local_orig_ret_0_1, local_orig_ret_0_2).into(); local_ret_0 }); };
local_ret.into()
}
#[must_use]
let mut rust_obj = NetGraphMsgHandler { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(NetGraphMsgHandler_free_void);
ret
}
pub(crate) fn take_inner(mut self) -> *mut nativeDirectionalChannelInfo {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
#[no_mangle]
pub extern "C" fn DirectionalChannelInfo_get_last_update_message(this_ptr: &DirectionalChannelInfo) -> crate::lightning::ln::msgs::ChannelUpdate {
let mut inner_val = &mut this_ptr.get_native_mut_ref().last_update_message;
- let mut local_inner_val = crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _ }, is_owned: false };
+ let mut local_inner_val = crate::lightning::ln::msgs::ChannelUpdate { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::ChannelUpdate<>) as *mut _ }, is_owned: false };
local_inner_val
}
/// Most recent update for the channel received from the network
impl Clone for DirectionalChannelInfo {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeDirectionalChannelInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeDirectionalChannelInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeChannelInfo {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
#[no_mangle]
pub extern "C" fn ChannelInfo_get_one_to_two(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::DirectionalChannelInfo {
let mut inner_val = &mut this_ptr.get_native_mut_ref().one_to_two;
- let mut local_inner_val = crate::lightning::routing::network_graph::DirectionalChannelInfo { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::network_graph::DirectionalChannelInfo<>) as *mut _ }, is_owned: false };
+ let mut local_inner_val = crate::lightning::routing::network_graph::DirectionalChannelInfo { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::network_graph::DirectionalChannelInfo<>) as *mut _ }, is_owned: false };
local_inner_val
}
/// Details about the first direction of a channel
#[no_mangle]
pub extern "C" fn ChannelInfo_get_two_to_one(this_ptr: &ChannelInfo) -> crate::lightning::routing::network_graph::DirectionalChannelInfo {
let mut inner_val = &mut this_ptr.get_native_mut_ref().two_to_one;
- let mut local_inner_val = crate::lightning::routing::network_graph::DirectionalChannelInfo { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::network_graph::DirectionalChannelInfo<>) as *mut _ }, is_owned: false };
+ let mut local_inner_val = crate::lightning::routing::network_graph::DirectionalChannelInfo { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::network_graph::DirectionalChannelInfo<>) as *mut _ }, is_owned: false };
local_inner_val
}
/// Details about the second direction of a channel
#[no_mangle]
pub extern "C" fn ChannelInfo_get_announcement_message(this_ptr: &ChannelInfo) -> crate::lightning::ln::msgs::ChannelAnnouncement {
let mut inner_val = &mut this_ptr.get_native_mut_ref().announcement_message;
- let mut local_inner_val = crate::lightning::ln::msgs::ChannelAnnouncement { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::ChannelAnnouncement<>) as *mut _ }, is_owned: false };
+ let mut local_inner_val = crate::lightning::ln::msgs::ChannelAnnouncement { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::ChannelAnnouncement<>) as *mut _ }, is_owned: false };
local_inner_val
}
/// An initial announcement of the channel
impl Clone for ChannelInfo {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeChannelInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeChannelInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeRoutingFees {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for RoutingFees {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeRoutingFees>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeRoutingFees>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
#[no_mangle]
pub extern "C" fn RoutingFees_hash(o: &RoutingFees) -> u64 {
if o.inner.is_null() { return 0; }
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
#[no_mangle]
/// Serialize the RoutingFees object into a byte array which can be read by RoutingFees_read
pub(crate) fn take_inner(mut self) -> *mut nativeNodeAnnouncementInfo {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
#[no_mangle]
pub extern "C" fn NodeAnnouncementInfo_get_announcement_message(this_ptr: &NodeAnnouncementInfo) -> crate::lightning::ln::msgs::NodeAnnouncement {
let mut inner_val = &mut this_ptr.get_native_mut_ref().announcement_message;
- let mut local_inner_val = crate::lightning::ln::msgs::NodeAnnouncement { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::NodeAnnouncement<>) as *mut _ }, is_owned: false };
+ let mut local_inner_val = crate::lightning::ln::msgs::NodeAnnouncement { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::msgs::NodeAnnouncement<>) as *mut _ }, is_owned: false };
local_inner_val
}
/// An initial announcement of the node
impl Clone for NodeAnnouncementInfo {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeNodeAnnouncementInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeNodeAnnouncementInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeNodeInfo {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
#[no_mangle]
pub extern "C" fn NodeInfo_get_lowest_inbound_channel_fees(this_ptr: &NodeInfo) -> crate::lightning::routing::network_graph::RoutingFees {
let mut inner_val = &mut this_ptr.get_native_mut_ref().lowest_inbound_channel_fees;
- let mut local_inner_val = crate::lightning::routing::network_graph::RoutingFees { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::network_graph::RoutingFees<>) as *mut _ }, is_owned: false };
+ let mut local_inner_val = crate::lightning::routing::network_graph::RoutingFees { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::network_graph::RoutingFees<>) as *mut _ }, is_owned: false };
local_inner_val
}
/// Lowest fees enabling routing via any of the enabled, known channels to a node.
#[no_mangle]
pub extern "C" fn NodeInfo_get_announcement_info(this_ptr: &NodeInfo) -> crate::lightning::routing::network_graph::NodeAnnouncementInfo {
let mut inner_val = &mut this_ptr.get_native_mut_ref().announcement_info;
- let mut local_inner_val = crate::lightning::routing::network_graph::NodeAnnouncementInfo { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::network_graph::NodeAnnouncementInfo<>) as *mut _ }, is_owned: false };
+ let mut local_inner_val = crate::lightning::routing::network_graph::NodeAnnouncementInfo { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::network_graph::NodeAnnouncementInfo<>) as *mut _ }, is_owned: false };
local_inner_val
}
/// More information about a node from node_announcement.
impl Clone for NodeInfo {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeNodeInfo>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeNodeInfo>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
//! You probably want to create a NetGraphMsgHandler and use that as your RoutingMessageHandler and then
//! interrogate it to get routes for your own payments.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
use lightning::routing::router::RouteHop as nativeRouteHopImport;
pub(crate) fn take_inner(mut self) -> *mut nativeRouteHop {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for RouteHop {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeRouteHop>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeRouteHop>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
#[no_mangle]
pub extern "C" fn RouteHop_hash(o: &RouteHop) -> u64 {
if o.inner.is_null() { return 0; }
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
/// Checks if two RouteHops contain equal inner contents.
/// This ignores pointers and is_owned flags and looks at the values in fields.
pub(crate) fn take_inner(mut self) -> *mut nativeRoute {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
#[no_mangle]
pub extern "C" fn Route_get_payee(this_ptr: &Route) -> crate::lightning::routing::router::Payee {
let mut inner_val = &mut this_ptr.get_native_mut_ref().payee;
- let mut local_inner_val = crate::lightning::routing::router::Payee { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::router::Payee<>) as *mut _ }, is_owned: false };
+ let mut local_inner_val = crate::lightning::routing::router::Payee { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::routing::router::Payee<>) as *mut _ }, is_owned: false };
local_inner_val
}
/// The `payee` parameter passed to [`find_route`].
impl Clone for Route {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeRoute>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeRoute>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
#[no_mangle]
pub extern "C" fn Route_hash(o: &Route) -> u64 {
if o.inner.is_null() { return 0; }
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
/// Checks if two Routes contain equal inner contents.
/// This ignores pointers and is_owned flags and looks at the values in fields.
pub(crate) fn take_inner(mut self) -> *mut nativeRouteParameters {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for RouteParameters {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeRouteParameters>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeRouteParameters>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativePayee {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
#[no_mangle]
pub extern "C" fn Payee_get_features(this_ptr: &Payee) -> crate::lightning::ln::features::InvoiceFeatures {
let mut inner_val = &mut this_ptr.get_native_mut_ref().features;
- let mut local_inner_val = crate::lightning::ln::features::InvoiceFeatures { inner: unsafe { (if inner_val.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::InvoiceFeatures<>) as *mut _ }, is_owned: false };
+ let mut local_inner_val = crate::lightning::ln::features::InvoiceFeatures { inner: unsafe { (if inner_val.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (inner_val.as_ref().unwrap()) }) } as *const lightning::ln::features::InvoiceFeatures<>) as *mut _ }, is_owned: false };
local_inner_val
}
/// Features supported by the payee.
impl Clone for Payee {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativePayee>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativePayee>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
#[no_mangle]
pub extern "C" fn Payee_hash(o: &Payee) -> u64 {
if o.inner.is_null() { return 0; }
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
/// Checks if two Payees contain equal inner contents.
/// This ignores pointers and is_owned flags and looks at the values in fields.
pub(crate) fn take_inner(mut self) -> *mut nativeRouteHint {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for RouteHint {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeRouteHint>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeRouteHint>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
#[no_mangle]
pub extern "C" fn RouteHint_hash(o: &RouteHint) -> u64 {
if o.inner.is_null() { return 0; }
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
/// Checks if two RouteHints contain equal inner contents.
/// This ignores pointers and is_owned flags and looks at the values in fields.
pub(crate) fn take_inner(mut self) -> *mut nativeRouteHintHop {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for RouteHintHop {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeRouteHintHop>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeRouteHintHop>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
#[no_mangle]
pub extern "C" fn RouteHintHop_hash(o: &RouteHintHop) -> u64 {
if o.inner.is_null() { return 0; }
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
/// Checks if two RouteHintHops contain equal inner contents.
/// This ignores pointers and is_owned flags and looks at the values in fields.
/// Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None
#[no_mangle]
pub extern "C" fn find_route(mut our_node_pubkey: crate::c_types::PublicKey, params: &crate::lightning::routing::router::RouteParameters, network: &crate::lightning::routing::network_graph::NetworkGraph, first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, mut logger: crate::lightning::util::logger::Logger, scorer: &crate::lightning::routing::scoring::Score) -> crate::c_types::derived::CResult_RouteLightningErrorZ {
- let mut local_first_hops_base = if first_hops == std::ptr::null_mut() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { item.get_native_ref() }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]);
+ let mut local_first_hops_base = if first_hops == core::ptr::null_mut() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { item.get_native_ref() }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]);
let mut ret = lightning::routing::router::find_route(&our_node_pubkey.into_rust(), params.get_native_ref(), network.get_native_ref(), local_first_hops, logger, scorer);
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
local_ret
//!
//! [`find_route`]: crate::routing::router::find_route
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
/// An interface used to score payment channels for path finding.
///
}
}
impl lightning::util::ser::Writeable for Score {
- fn write<W: lightning::util::ser::Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {
+ fn write<W: lightning::util::ser::Writer>(&self, w: &mut W) -> Result<(), crate::c_types::io::Error> {
let vec = (self.write)(self.this_arg);
w.write_all(vec.as_slice())
}
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for Score {
+impl core::ops::Deref for Score {
type Target = Self;
fn deref(&self) -> &Self {
self
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for LockableScore {
+impl core::ops::Deref for LockableScore {
type Target = Self;
fn deref(&self) -> &Self {
self
pub(crate) fn take_inner(mut self) -> *mut nativeMultiThreadedLockableScore {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
pub(crate) fn take_inner(mut self) -> *mut nativeScorer {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
pub(crate) fn take_inner(mut self) -> *mut nativeScoringParameters {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
/// [`failure_penalty_msat`]: Self::failure_penalty_msat
#[no_mangle]
pub extern "C" fn ScoringParameters_set_failure_penalty_half_life(this_ptr: &mut ScoringParameters, mut val: u64) {
- unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_penalty_half_life = std::time::Duration::from_secs(val);
+ unsafe { &mut *ObjOps::untweak_ptr(this_ptr.inner) }.failure_penalty_half_life = core::time::Duration::from_secs(val);
}
/// Constructs a new ScoringParameters given each field
#[must_use]
failure_penalty_msat: failure_penalty_msat_arg,
overuse_penalty_start_1024th: overuse_penalty_start_1024th_arg,
overuse_penalty_msat_per_1024th: overuse_penalty_msat_per_1024th_arg,
- failure_penalty_half_life: std::time::Duration::from_secs(failure_penalty_half_life_arg),
+ failure_penalty_half_life: core::time::Duration::from_secs(failure_penalty_half_life_arg),
}), is_owned: true }
}
#[no_mangle]
let mut rust_obj = Scorer { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = Scorer_as_Score(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(Scorer_free_void);
ret
}
}
mod time {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
//! Various user-configurable channel limits and settings which ChannelManager
//! applies for you.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
use lightning::util::config::ChannelHandshakeConfig as nativeChannelHandshakeConfigImport;
pub(crate) fn take_inner(mut self) -> *mut nativeChannelHandshakeConfig {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ChannelHandshakeConfig {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeChannelHandshakeConfig>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeChannelHandshakeConfig>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeChannelHandshakeLimits {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ChannelHandshakeLimits {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeChannelHandshakeLimits>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeChannelHandshakeLimits>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeChannelConfig {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ChannelConfig {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeChannelConfig>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeChannelConfig>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeUserConfig {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for UserConfig {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeUserConfig>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeUserConfig>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
//! Error types live here.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
/// Indicates an error on the client's part (usually some variant of attempting to use too-low or
/// too-high values)
//! future, as well as generate and broadcast funding transactions handle payment preimages and a
//! few other things.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
/// Some information provided on receipt of payment depends on whether the payment received is a
/// spontaneous payment or a \"conventional\" lightning payment that's paying an invoice.
Event::PendingHTLCsForwardable {ref time_forwardable, } => {
let mut time_forwardable_nonref = (*time_forwardable).clone();
nativeEvent::PendingHTLCsForwardable {
- time_forwardable: std::time::Duration::from_secs(time_forwardable_nonref),
+ time_forwardable: core::time::Duration::from_secs(time_forwardable_nonref),
}
},
Event::SpendableOutputs {ref outputs, } => {
},
Event::PendingHTLCsForwardable {mut time_forwardable, } => {
nativeEvent::PendingHTLCsForwardable {
- time_forwardable: std::time::Duration::from_secs(time_forwardable),
+ time_forwardable: core::time::Duration::from_secs(time_forwardable),
}
},
Event::SpendableOutputs {mut outputs, } => {
let mut short_channel_id_nonref = (*short_channel_id).clone();
let mut local_short_channel_id_nonref = if short_channel_id_nonref.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id_nonref.unwrap() }) };
let mut retry_nonref = (*retry).clone();
- let mut local_retry_nonref = crate::lightning::routing::router::RouteParameters { inner: if retry_nonref.is_none() { std::ptr::null_mut() } else { { ObjOps::heap_alloc((retry_nonref.unwrap())) } }, is_owned: true };
+ let mut local_retry_nonref = crate::lightning::routing::router::RouteParameters { inner: if retry_nonref.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((retry_nonref.unwrap())) } }, is_owned: true };
Event::PaymentPathFailed {
payment_id: local_payment_id_nonref,
payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash_nonref.0 },
let mut local_network_update = if network_update.is_none() { crate::c_types::derived::COption_NetworkUpdateZ::None } else { crate::c_types::derived::COption_NetworkUpdateZ::Some( { crate::lightning::routing::network_graph::NetworkUpdate::native_into(network_update.unwrap()) }) };
let mut local_path = Vec::new(); for mut item in path.drain(..) { local_path.push( { crate::lightning::routing::router::RouteHop { inner: ObjOps::heap_alloc(item), is_owned: true } }); };
let mut local_short_channel_id = if short_channel_id.is_none() { crate::c_types::derived::COption_u64Z::None } else { crate::c_types::derived::COption_u64Z::Some( { short_channel_id.unwrap() }) };
- let mut local_retry = crate::lightning::routing::router::RouteParameters { inner: if retry.is_none() { std::ptr::null_mut() } else { { ObjOps::heap_alloc((retry.unwrap())) } }, is_owned: true };
+ let mut local_retry = crate::lightning::routing::router::RouteParameters { inner: if retry.is_none() { core::ptr::null_mut() } else { { ObjOps::heap_alloc((retry.unwrap())) } }, is_owned: true };
Event::PaymentPathFailed {
payment_id: local_payment_id,
payment_hash: crate::c_types::ThirtyTwoBytes { data: payment_hash.0 },
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for MessageSendEventsProvider {
+impl core::ops::Deref for MessageSendEventsProvider {
type Target = Self;
fn deref(&self) -> &Self {
self
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for EventHandler {
+impl core::ops::Deref for EventHandler {
type Target = Self;
fn deref(&self) -> &Self {
self
//! The second one, client-side by implementing check against Record Level field.
//! Each module may have its own Logger or share one.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
/// An enum representing the available verbosity levels of the logger.
#[must_use]
/// Checks if two Levels contain equal inner contents.
#[no_mangle]
pub extern "C" fn Level_hash(o: &Level) -> u64 {
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(&o.to_native(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(&o.to_native(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
/// Returns the most verbose logging level.
#[must_use]
pub(crate) fn take_inner(mut self) -> *mut nativeRecord {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for Record {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeRecord>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeRecord>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for Logger {
+impl core::ops::Deref for Logger {
type Target = Self;
fn deref(&self) -> &Self {
self
//! <https://lightning.readthedocs.io/lightning-signmessage.7.html>
//! <https://api.lightning.community/#signmessage>
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
/// Creates a digital signature of a message given a SecretKey, like the node's secret.
/// A receiver knowing the PublicKey (e.g. the node's id) and the message can be sure that the signature was generated by the caller.
//! Some utility modules live here. See individual sub-modules for more info.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
pub mod events;
pub mod errors;
pub mod config;
mod fuzz_wrappers {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
mod ser_macros {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
mod atomic_counter {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
mod byte_utils {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
mod chacha20 {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
mod real_chacha {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
}
mod zbase32 {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
mod poly1305 {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
mod chacha20poly1305rfc {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
mod real_chachapoly {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
}
mod transaction_utils {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
mod scid_utils {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
mod macro_logger {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
//! A very simple serialization framework which is used to serialize/deserialize messages as well
//! as ChannelsManagers and ChannelMonitors.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
/// serialization buffer size
//! running properly, and (2) either can or should be run in the background. See docs for
//! [`BackgroundProcessor`] for more details on the nitty-gritty.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
use lightning_background_processor::BackgroundProcessor as nativeBackgroundProcessorImport;
pub(crate) fn take_inner(mut self) -> *mut nativeBackgroundProcessor {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for ChannelManagerPersister {
+impl core::ops::Deref for ChannelManagerPersister {
type Target = Self;
fn deref(&self) -> &Self {
self
/// Tag constants as specified in BOLT11
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
#[no_mangle]
//! * For constructing invoices use the `InvoiceBuilder`
//! * For serializing invoices use the `Display`/`ToString` traits
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
pub mod payment;
pub mod utils;
pub mod constants;
mod de {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
mod hrp_sm {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
#[no_mangle]
}
mod ser {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
#[no_mangle]
/// Get the string representation of a Invoice object
}
mod tb {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
/// Default expiry time as defined by [BOLT 11].
pub(crate) fn take_inner(mut self) -> *mut nativeInvoice {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for Invoice {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeInvoice>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeInvoice>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeSignedRawInvoice {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for SignedRawInvoice {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeSignedRawInvoice>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeSignedRawInvoice>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeRawInvoice {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for RawInvoice {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeRawInvoice>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeRawInvoice>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativeRawDataPart {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for RawDataPart {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeRawDataPart>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeRawDataPart>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativePositiveTimestamp {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for PositiveTimestamp {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativePositiveTimestamp>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativePositiveTimestamp>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
/// Checks if two Currencys contain equal inner contents.
#[no_mangle]
pub extern "C" fn Currency_hash(o: &Currency) -> u64 {
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(&o.to_native(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(&o.to_native(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
/// Checks if two Currencys contain equal inner contents.
/// This ignores pointers and is_owned flags and looks at the values in fields.
pub(crate) fn take_inner(mut self) -> *mut nativeSha256 {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for Sha256 {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeSha256>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeSha256>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
#[no_mangle]
pub extern "C" fn Sha256_hash(o: &Sha256) -> u64 {
if o.inner.is_null() { return 0; }
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
/// Checks if two Sha256s contain equal inner contents.
/// This ignores pointers and is_owned flags and looks at the values in fields.
pub(crate) fn take_inner(mut self) -> *mut nativeDescription {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for Description {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeDescription>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeDescription>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
#[no_mangle]
pub extern "C" fn Description_hash(o: &Description) -> u64 {
if o.inner.is_null() { return 0; }
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
/// Checks if two Descriptions contain equal inner contents.
/// This ignores pointers and is_owned flags and looks at the values in fields.
pub(crate) fn take_inner(mut self) -> *mut nativePayeePubKey {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for PayeePubKey {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativePayeePubKey>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativePayeePubKey>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
#[no_mangle]
pub extern "C" fn PayeePubKey_hash(o: &PayeePubKey) -> u64 {
if o.inner.is_null() { return 0; }
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
/// Checks if two PayeePubKeys contain equal inner contents.
/// This ignores pointers and is_owned flags and looks at the values in fields.
pub(crate) fn take_inner(mut self) -> *mut nativeExpiryTime {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for ExpiryTime {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeExpiryTime>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeExpiryTime>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
#[no_mangle]
pub extern "C" fn ExpiryTime_hash(o: &ExpiryTime) -> u64 {
if o.inner.is_null() { return 0; }
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
/// Checks if two ExpiryTimes contain equal inner contents.
/// This ignores pointers and is_owned flags and looks at the values in fields.
pub(crate) fn take_inner(mut self) -> *mut nativeMinFinalCltvExpiry {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for MinFinalCltvExpiry {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeMinFinalCltvExpiry>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeMinFinalCltvExpiry>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
#[no_mangle]
pub extern "C" fn MinFinalCltvExpiry_hash(o: &MinFinalCltvExpiry) -> u64 {
if o.inner.is_null() { return 0; }
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
/// Checks if two MinFinalCltvExpirys contain equal inner contents.
/// This ignores pointers and is_owned flags and looks at the values in fields.
/// Checks if two Fallbacks contain equal inner contents.
#[no_mangle]
pub extern "C" fn Fallback_hash(o: &Fallback) -> u64 {
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(&o.to_native(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(&o.to_native(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
/// Checks if two Fallbacks contain equal inner contents.
/// This ignores pointers and is_owned flags and looks at the values in fields.
pub(crate) fn take_inner(mut self) -> *mut nativeInvoiceSignature {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for InvoiceSignature {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeInvoiceSignature>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeInvoiceSignature>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
pub(crate) fn take_inner(mut self) -> *mut nativePrivateRoute {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for PrivateRoute {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativePrivateRoute>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativePrivateRoute>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
#[no_mangle]
pub extern "C" fn PrivateRoute_hash(o: &PrivateRoute) -> u64 {
if o.inner.is_null() { return 0; }
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
/// Checks if two PrivateRoutes contain equal inner contents.
/// This ignores pointers and is_owned flags and looks at the values in fields.
#[no_mangle]
pub extern "C" fn RawInvoice_payment_hash(this_arg: &RawInvoice) -> crate::lightning_invoice::Sha256 {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payment_hash();
- let mut local_ret = crate::lightning_invoice::Sha256 { inner: unsafe { (if ret.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::Sha256<>) as *mut _ }, is_owned: false };
+ let mut local_ret = crate::lightning_invoice::Sha256 { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::Sha256<>) as *mut _ }, is_owned: false };
local_ret
}
#[no_mangle]
pub extern "C" fn RawInvoice_description(this_arg: &RawInvoice) -> crate::lightning_invoice::Description {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description();
- let mut local_ret = crate::lightning_invoice::Description { inner: unsafe { (if ret.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::Description<>) as *mut _ }, is_owned: false };
+ let mut local_ret = crate::lightning_invoice::Description { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::Description<>) as *mut _ }, is_owned: false };
local_ret
}
#[no_mangle]
pub extern "C" fn RawInvoice_payee_pub_key(this_arg: &RawInvoice) -> crate::lightning_invoice::PayeePubKey {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.payee_pub_key();
- let mut local_ret = crate::lightning_invoice::PayeePubKey { inner: unsafe { (if ret.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::PayeePubKey<>) as *mut _ }, is_owned: false };
+ let mut local_ret = crate::lightning_invoice::PayeePubKey { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::PayeePubKey<>) as *mut _ }, is_owned: false };
local_ret
}
#[no_mangle]
pub extern "C" fn RawInvoice_description_hash(this_arg: &RawInvoice) -> crate::lightning_invoice::Sha256 {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.description_hash();
- let mut local_ret = crate::lightning_invoice::Sha256 { inner: unsafe { (if ret.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::Sha256<>) as *mut _ }, is_owned: false };
+ let mut local_ret = crate::lightning_invoice::Sha256 { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::Sha256<>) as *mut _ }, is_owned: false };
local_ret
}
#[no_mangle]
pub extern "C" fn RawInvoice_expiry_time(this_arg: &RawInvoice) -> crate::lightning_invoice::ExpiryTime {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.expiry_time();
- let mut local_ret = crate::lightning_invoice::ExpiryTime { inner: unsafe { (if ret.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::ExpiryTime<>) as *mut _ }, is_owned: false };
+ let mut local_ret = crate::lightning_invoice::ExpiryTime { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::ExpiryTime<>) as *mut _ }, is_owned: false };
local_ret
}
#[no_mangle]
pub extern "C" fn RawInvoice_min_final_cltv_expiry(this_arg: &RawInvoice) -> crate::lightning_invoice::MinFinalCltvExpiry {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.min_final_cltv_expiry();
- let mut local_ret = crate::lightning_invoice::MinFinalCltvExpiry { inner: unsafe { (if ret.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::MinFinalCltvExpiry<>) as *mut _ }, is_owned: false };
+ let mut local_ret = crate::lightning_invoice::MinFinalCltvExpiry { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning_invoice::MinFinalCltvExpiry<>) as *mut _ }, is_owned: false };
local_ret
}
#[no_mangle]
pub extern "C" fn RawInvoice_features(this_arg: &RawInvoice) -> crate::lightning::ln::features::InvoiceFeatures {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features();
- let mut local_ret = crate::lightning::ln::features::InvoiceFeatures { inner: unsafe { (if ret.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::InvoiceFeatures<>) as *mut _ }, is_owned: false };
+ let mut local_ret = crate::lightning::ln::features::InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::InvoiceFeatures<>) as *mut _ }, is_owned: false };
local_ret
}
#[no_mangle]
pub extern "C" fn Invoice_features(this_arg: &Invoice) -> crate::lightning::ln::features::InvoiceFeatures {
let mut ret = unsafe { &*ObjOps::untweak_ptr(this_arg.inner) }.features();
- let mut local_ret = crate::lightning::ln::features::InvoiceFeatures { inner: unsafe { (if ret.is_none() { std::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::InvoiceFeatures<>) as *mut _ }, is_owned: false };
+ let mut local_ret = crate::lightning::ln::features::InvoiceFeatures { inner: unsafe { (if ret.is_none() { core::ptr::null() } else { ObjOps::nonnull_ptr_to_inner( { (ret.unwrap()) }) } as *const lightning::ln::features::InvoiceFeatures<>) as *mut _ }, is_owned: false };
local_ret
}
#[must_use]
#[no_mangle]
pub extern "C" fn ExpiryTime_from_duration(mut duration: u64) -> crate::c_types::derived::CResult_ExpiryTimeCreationErrorZ {
- let mut ret = lightning_invoice::ExpiryTime::from_duration(std::time::Duration::from_secs(duration));
+ let mut ret = lightning_invoice::ExpiryTime::from_duration(core::time::Duration::from_secs(duration));
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning_invoice::ExpiryTime { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning_invoice::CreationError::native_into(e) }).into() };
local_ret
}
//! as updates to the network graph or changes to channel scores should be applied prior to
//! retries, typically by way of composing [`EventHandler`]s accordingly.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
use lightning_invoice::payment::InvoicePayer as nativeInvoicePayerImport;
pub(crate) fn take_inner(mut self) -> *mut nativeInvoicePayer {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for Payer {
+impl core::ops::Deref for Payer {
type Target = Self;
fn deref(&self) -> &Self {
self
// We're essentially a pointer already, or at least a set of pointers, so allow us to be used
// directly as a Deref trait in higher-level structs:
-impl std::ops::Deref for Router {
+impl core::ops::Deref for Router {
type Target = Self;
fn deref(&self) -> &Self {
self
pub(crate) fn take_inner(mut self) -> *mut nativeRetryAttempts {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
impl Clone for RetryAttempts {
fn clone(&self) -> Self {
Self {
- inner: if <*mut nativeRetryAttempts>::is_null(self.inner) { std::ptr::null_mut() } else {
+ inner: if <*mut nativeRetryAttempts>::is_null(self.inner) { core::ptr::null_mut() } else {
ObjOps::heap_alloc(unsafe { &*ObjOps::untweak_ptr(self.inner) }.clone()) },
is_owned: true,
}
#[no_mangle]
pub extern "C" fn RetryAttempts_hash(o: &RetryAttempts) -> u64 {
if o.inner.is_null() { return 0; }
- // Note that we'd love to use std::collections::hash_map::DefaultHasher but it's not in core
+ // Note that we'd love to use alloc::collections::hash_map::DefaultHasher but it's not in core
#[allow(deprecated)]
let mut hasher = core::hash::SipHasher::new();
- std::hash::Hash::hash(o.get_native_ref(), &mut hasher);
- std::hash::Hasher::finish(&hasher)
+ core::hash::Hash::hash(o.get_native_ref(), &mut hasher);
+ core::hash::Hasher::finish(&hasher)
}
/// An error that may occur when making a payment.
#[must_use]
let mut rust_obj = InvoicePayer { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = InvoicePayer_as_EventHandler(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(InvoicePayer_free_void);
ret
}
//! Convenient utilities to create an invoice.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
/// Utility to construct an invoice. Generally, unless you want to do something like a custom
/// cltv_expiry, this is what you should be using to create an invoice. The reason being, this
pub(crate) fn take_inner(mut self) -> *mut nativeDefaultRouter {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
let mut rust_obj = DefaultRouter { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = DefaultRouter_as_Router(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(DefaultRouter_free_void);
ret
}
#[must_use]
extern "C" fn DefaultRouter_Router_find_route(this_arg: *const c_void, mut payer: crate::c_types::PublicKey, params: &crate::lightning::routing::router::RouteParameters, _payment_hash: *const [u8; 32], first_hops: *mut crate::c_types::derived::CVec_ChannelDetailsZ, scorer: &crate::lightning::routing::scoring::Score) -> crate::c_types::derived::CResult_RouteLightningErrorZ {
- let mut local_first_hops_base = if first_hops == std::ptr::null_mut() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { item.get_native_ref() }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]);
+ let mut local_first_hops_base = if first_hops == core::ptr::null_mut() { None } else { Some( { let mut local_first_hops_0 = Vec::new(); for mut item in unsafe { &mut *first_hops }.as_slice().iter() { local_first_hops_0.push( { item.get_native_ref() }); }; local_first_hops_0 }) }; let mut local_first_hops = local_first_hops_base.as_ref().map(|a| &a[..]);
let mut ret = <nativeDefaultRouter as lightning_invoice::payment::Router<_>>::find_route(unsafe { &mut *(this_arg as *mut nativeDefaultRouter) }, &payer.into_rust(), params.get_native_ref(), &::lightning::ln::PaymentHash(unsafe { *_payment_hash }), local_first_hops, scorer);
let mut local_ret = match ret { Ok(mut o) => crate::c_types::CResultTempl::ok( { crate::lightning::routing::router::Route { inner: ObjOps::heap_alloc(o), is_owned: true } }).into(), Err(mut e) => crate::c_types::CResultTempl::err( { crate::lightning::ln::msgs::LightningError { inner: ObjOps::heap_alloc(e), is_owned: true } }).into() };
local_ret
let mut rust_obj = ChannelManager { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = ChannelManager_as_Payer(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(ChannelManager_free_void);
ret
}
//! Utilities that handle persisting Rust-Lightning data to disk via standard filesystem APIs.
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
mod util {
-use std::str::FromStr;
-use std::ffi::c_void;
+use alloc::str::FromStr;
+use core::ffi::c_void;
use core::convert::Infallible;
use bitcoin::hashes::Hash;
use crate::c_types::*;
+#[cfg(feature="no-std")]
+use alloc::{vec::Vec, boxed::Box};
}
pub(crate) fn take_inner(mut self) -> *mut nativeFilesystemPersister {
assert!(self.is_owned);
let ret = ObjOps::untweak_ptr(self.inner);
- self.inner = std::ptr::null_mut();
+ self.inner = core::ptr::null_mut();
ret
}
}
let mut rust_obj = FilesystemPersister { inner: ObjOps::heap_alloc(obj), is_owned: true };
let mut ret = FilesystemPersister_as_Persist(&rust_obj);
// We want to free rust_obj when ret gets drop()'d, not rust_obj, so wipe rust_obj's pointer and set ret's free() fn
- rust_obj.inner = std::ptr::null_mut();
+ rust_obj.inner = core::ptr::null_mut();
ret.free = Some(FilesystemPersister_free_void);
ret
}