|
@@ -18,7 +18,7 @@ fn track_notify_fn(
|
|
|
println!(" New value: {new_value}");
|
|
println!(" New value: {new_value}");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-fn main() {
|
|
|
|
|
|
|
+fn main() -> Result<(), corosync::CsError> {
|
|
|
let handle = match cmap::initialize(cmap::Map::Icmap) {
|
|
let handle = match cmap::initialize(cmap::Map::Icmap) {
|
|
|
Ok(h) => {
|
|
Ok(h) => {
|
|
|
println!("cmap initialized.");
|
|
println!("cmap initialized.");
|
|
@@ -26,48 +26,48 @@ fn main() {
|
|
|
}
|
|
}
|
|
|
Err(e) => {
|
|
Err(e) => {
|
|
|
println!("Error in CMAP (Icmap) init: {e}");
|
|
println!("Error in CMAP (Icmap) init: {e}");
|
|
|
- return;
|
|
|
|
|
|
|
+ return Err(e);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// Test some SETs
|
|
// Test some SETs
|
|
|
if let Err(e) = cmap::set_u32(&handle, "test.test_uint32", 456) {
|
|
if let Err(e) = cmap::set_u32(&handle, "test.test_uint32", 456) {
|
|
|
println!("Error in CMAP set_u32: {e}");
|
|
println!("Error in CMAP set_u32: {e}");
|
|
|
- return;
|
|
|
|
|
|
|
+ return Err(e);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
if let Err(e) = cmap::set_i16(&handle, "test.test_int16", -789) {
|
|
if let Err(e) = cmap::set_i16(&handle, "test.test_int16", -789) {
|
|
|
println!("Error in CMAP set_i16: {e}");
|
|
println!("Error in CMAP set_i16: {e}");
|
|
|
- return;
|
|
|
|
|
|
|
+ return Err(e);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
if let Err(e) = cmap::set_number(&handle, "test.test_num_1", 6809u32) {
|
|
if let Err(e) = cmap::set_number(&handle, "test.test_num_1", 6809u32) {
|
|
|
println!("Error in CMAP set_number(u32): {e}");
|
|
println!("Error in CMAP set_number(u32): {e}");
|
|
|
- return;
|
|
|
|
|
|
|
+ return Err(e);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// NOT PI (just to avoid clippy whingeing)
|
|
// NOT PI (just to avoid clippy whingeing)
|
|
|
if let Err(e) = cmap::set_number(&handle, "test.test_num_2", 3.24159265) {
|
|
if let Err(e) = cmap::set_number(&handle, "test.test_num_2", 3.24159265) {
|
|
|
println!("Error in CMAP set_number(f32): {e}");
|
|
println!("Error in CMAP set_number(f32): {e}");
|
|
|
- return;
|
|
|
|
|
|
|
+ return Err(e);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
if let Err(e) = cmap::set_string(&handle, "test.test_string", "Hello from Rust") {
|
|
if let Err(e) = cmap::set_string(&handle, "test.test_string", "Hello from Rust") {
|
|
|
println!("Error in CMAP set_string: {e}");
|
|
println!("Error in CMAP set_string: {e}");
|
|
|
- return;
|
|
|
|
|
|
|
+ return Err(e);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
let test_d = cmap::Data::UInt64(0xdeadbeefbacecafe);
|
|
let test_d = cmap::Data::UInt64(0xdeadbeefbacecafe);
|
|
|
if let Err(e) = cmap::set(&handle, "test.test_data", &test_d) {
|
|
if let Err(e) = cmap::set(&handle, "test.test_data", &test_d) {
|
|
|
println!("Error in CMAP set_data: {e}");
|
|
println!("Error in CMAP set_data: {e}");
|
|
|
- return;
|
|
|
|
|
|
|
+ return Err(e);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// let test_d2 = cmap::Data::UInt32(6809);
|
|
// let test_d2 = cmap::Data::UInt32(6809);
|
|
|
let test_d2 = cmap::Data::String("Test string in data 12345".to_string());
|
|
let test_d2 = cmap::Data::String("Test string in data 12345".to_string());
|
|
|
if let Err(e) = cmap::set(&handle, "test.test_again", &test_d2) {
|
|
if let Err(e) = cmap::set(&handle, "test.test_again", &test_d2) {
|
|
|
println!("Error in CMAP set_data2: {e}");
|
|
println!("Error in CMAP set_data2: {e}");
|
|
|
- return;
|
|
|
|
|
|
|
+ return Err(e);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// get them back again
|
|
// get them back again
|
|
@@ -78,7 +78,7 @@ fn main() {
|
|
|
|
|
|
|
|
Err(e) => {
|
|
Err(e) => {
|
|
|
println!("Error in CMAP get: {e}");
|
|
println!("Error in CMAP get: {e}");
|
|
|
- return;
|
|
|
|
|
|
|
+ return Err(e);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
match cmap::get(&handle, "test.test_int16") {
|
|
match cmap::get(&handle, "test.test_int16") {
|
|
@@ -88,7 +88,7 @@ fn main() {
|
|
|
|
|
|
|
|
Err(e) => {
|
|
Err(e) => {
|
|
|
println!("Error in CMAP get: {e}");
|
|
println!("Error in CMAP get: {e}");
|
|
|
- return;
|
|
|
|
|
|
|
+ return Err(e);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -99,7 +99,7 @@ fn main() {
|
|
|
|
|
|
|
|
Err(e) => {
|
|
Err(e) => {
|
|
|
println!("Error in CMAP get: {e}");
|
|
println!("Error in CMAP get: {e}");
|
|
|
- return;
|
|
|
|
|
|
|
+ return Err(e);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
match cmap::get(&handle, "test.test_num_2") {
|
|
match cmap::get(&handle, "test.test_num_2") {
|
|
@@ -109,7 +109,7 @@ fn main() {
|
|
|
|
|
|
|
|
Err(e) => {
|
|
Err(e) => {
|
|
|
println!("Error in CMAP get: {e}");
|
|
println!("Error in CMAP get: {e}");
|
|
|
- return;
|
|
|
|
|
|
|
+ return Err(e);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
match cmap::get(&handle, "test.test_string") {
|
|
match cmap::get(&handle, "test.test_string") {
|
|
@@ -119,7 +119,7 @@ fn main() {
|
|
|
|
|
|
|
|
Err(e) => {
|
|
Err(e) => {
|
|
|
println!("Error in CMAP get: {e}");
|
|
println!("Error in CMAP get: {e}");
|
|
|
- return;
|
|
|
|
|
|
|
+ return Err(e);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -131,7 +131,7 @@ fn main() {
|
|
|
|
|
|
|
|
Err(e) => {
|
|
Err(e) => {
|
|
|
println!("Error in CMAP get: {e}");
|
|
println!("Error in CMAP get: {e}");
|
|
|
- return;
|
|
|
|
|
|
|
+ return Err(e);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -151,7 +151,7 @@ fn main() {
|
|
|
// Close this handle
|
|
// Close this handle
|
|
|
if let Err(e) = cmap::finalize(&handle) {
|
|
if let Err(e) = cmap::finalize(&handle) {
|
|
|
println!("Error in CMAP get: {e}");
|
|
println!("Error in CMAP get: {e}");
|
|
|
- return;
|
|
|
|
|
|
|
+ return Err(e);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
// Test notifications on the stats map
|
|
// Test notifications on the stats map
|
|
@@ -159,7 +159,7 @@ fn main() {
|
|
|
Ok(h) => h,
|
|
Ok(h) => h,
|
|
|
Err(e) => {
|
|
Err(e) => {
|
|
|
println!("Error in CMAP (Stats) init: {e}");
|
|
println!("Error in CMAP (Stats) init: {e}");
|
|
|
- return;
|
|
|
|
|
|
|
+ return Err(e);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -176,11 +176,11 @@ fn main() {
|
|
|
Ok(th) => th,
|
|
Ok(th) => th,
|
|
|
Err(e) => {
|
|
Err(e) => {
|
|
|
println!("Error in CMAP track_add {e}");
|
|
println!("Error in CMAP track_add {e}");
|
|
|
- return;
|
|
|
|
|
|
|
+ return Err(e);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- // Wait for events
|
|
|
|
|
|
|
+ // Wait for some events
|
|
|
let mut event_num = 0;
|
|
let mut event_num = 0;
|
|
|
loop {
|
|
loop {
|
|
|
if let Err(e) = cmap::dispatch(&handle, corosync::DispatchFlags::One) {
|
|
if let Err(e) = cmap::dispatch(&handle, corosync::DispatchFlags::One) {
|
|
@@ -192,4 +192,5 @@ fn main() {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ Ok(())
|
|
|
}
|
|
}
|