Unfortunately I was able to make objcopy work only up to 113,650 bytes 😞
There are two main components to any project that uses elfredo:
get_embedded_data
method to retrieve the embeddedAfter these two are implemented you end up with two binaries:
Steps to integrate (See ./example
):
// my_embeditor.rs
use elfredo::embeditor::run_embeditor;
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
pub struct Person {
name: String,
id: u32,
}
fn main() {
// This will print the embedded data if exists
if let Err(err) = run_embeditor::<Person>() {
panic!("{}", err);
}
}
// main.rs
use elfredo::get_embedded_data;
mod my_embeditor;
use my_embeditor::Person;
fn main() -> Result<(), failure::Error> {
let person = get_embedded_data::<Person>().unwrap();
println!("{:?}", person);
Ok(())
}
john@ubuntu:/mnt/hgfs/elfredo/example$ cat person.json
{
"name": "Ronald",
"id": 5
}
john@ubuntu:/mnt/hgfs/elfredo/example$ cargo run --bin embeditor ../target/debug/example person.json
Compiling elfredo v0.1.0 (/mnt/hgfs/elfredo)
Compiling example v0.1.0 (/mnt/hgfs/elfredo/example)
Finished dev [unoptimized + debuginfo] target(s) in 24.99s
Running `/mnt/hgfs/elfredo/target/debug/embeditor ../target/debug/example person.json`
"/tmp/.tmpXh5QHg"
john@ubuntu:/mnt/hgfs/elfredo/example$ ../target/debug/example
Person { name: "Ronald", id: 5 }