Skip to content

Commit

Permalink
chore: get lib absolute path in order to read the _data folder
Browse files Browse the repository at this point in the history
  • Loading branch information
omdxp committed Jan 2, 2024
1 parent 6d19679 commit defeb73
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use std::fs;

use serde::{Deserialize, Serialize};

const DATA_FOLDER: &'static str = "src/_data";
static DATA_FOLDER: &'static str = "src/_data";
static CARGO_MANIFEST_DIR: &'static str = env!("CARGO_MANIFEST_DIR");

#[derive(Debug, Serialize, Deserialize)]
struct Name {
Expand Down Expand Up @@ -47,7 +48,9 @@ pub struct Schema {
}

pub fn get_node_by_path(path: &str) -> Option<Schema> {
let fs_path = format!("{}/{}/info.json", DATA_FOLDER, path);
let fs_path = format!("{}/{}/{}/info.json", CARGO_MANIFEST_DIR, DATA_FOLDER, path);
let x = env!("CARGO_MANIFEST_DIR");
dbg!(&x);
let Ok(info) = fs::read_to_string(fs_path) else {
return None;
};
Expand Down

0 comments on commit defeb73

Please sign in to comment.