MCPcopy Index your code
hub / github.com/cargo-lambda/cargo-lambda / read_binary

Function read_binary

crates/cargo-lambda-build/src/archive.rs:344–366  ·  view source on GitHub ↗
(
    entry: &mut R,
    binary_path: D,
)

Source from the content-addressed store, hash-verified

342}
343
344fn read_binary<'a, R: Read, D: std::fmt::Debug>(
345 entry: &mut R,
346 binary_path: D,
347) -> Result<(Vec<u8>, &'a str)> {
348 let mut binary_data = Vec::new();
349
350 entry
351 .read_to_end(&mut binary_data)
352 .into_diagnostic()
353 .wrap_err_with(|| format!("failed to read binary file `{binary_path:?}`"))?;
354
355 let object = ObjectFile::parse(&*binary_data)
356 .into_diagnostic()
357 .wrap_err("the provided function file is not a valid Linux binary")?;
358
359 let arch = match object.architecture() {
360 Architecture::Aarch64 => "arm64",
361 Architecture::X86_64 => "x86_64",
362 other => return Err(BuildError::InvalidBinaryArchitecture(other).into()),
363 };
364
365 Ok((binary_data, arch))
366}
367
368fn zip_file_options(file: &File, path: &Path) -> Result<SimpleFileOptions> {
369 let meta = file

Callers 2

zip_binaryFunction · 0.85

Calls 2

newFunction · 0.85
architectureMethod · 0.80

Tested by

no test coverage detected