Skip to content

Commit

Permalink
Make run_app in inspector take a slice instead of path (#206)
Browse files Browse the repository at this point in the history
This is a much more ergonomic api when creating a custom loader,
as the flatbuffer data might be offset, compressed, or otherwise
not loadable from a path
  • Loading branch information
kristoff3r authored Oct 22, 2023
1 parent d06beec commit 1af9352
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 2 additions & 1 deletion crates/planus-cli/src/app/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub struct Command {

impl Command {
pub fn run(self, _options: super::AppOptions) -> Result<ExitCode> {
planus_inspector::app::run_app(&self.schema_file, &self.root_type, &self.data_file)
let buffer = std::fs::read(&self.data_file)?;
planus_inspector::app::run_app(&self.schema_file, &self.root_type, &buffer)
}
}
6 changes: 2 additions & 4 deletions crates/planus-inspector/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ use tui::{backend::CrosstermBackend, Terminal};

use crate::{run_inspector, Inspector};

pub fn run_app(schema_file: &Path, root_type: &str, data_file: &Path) -> Result<ExitCode> {
let buffer = std::fs::read(data_file)?;

pub fn run_app(schema_file: &Path, root_type: &str, buffer: &[u8]) -> Result<ExitCode> {
let Some(declarations) = translate_files(&[schema_file]) else {
return Ok(ExitCode::FAILURE);
};
Expand Down Expand Up @@ -66,7 +64,7 @@ pub fn run_app(schema_file: &Path, root_type: &str, data_file: &Path) -> Result<
let inspector = Inspector::new(
planus_buffer_inspection::InspectableFlatbuffer {
declarations: &declarations,
buffer: &buffer,
buffer,
},
DeclarationIndex(root_table_index),
);
Expand Down

0 comments on commit 1af9352

Please sign in to comment.