-
Notifications
You must be signed in to change notification settings - Fork 923
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Modularize: split out misc.rs for general stuff
- Loading branch information
Showing
18 changed files
with
233 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,6 @@ | |
/cxx.h | ||
/lib.rs.h | ||
/web.rs.h | ||
/misc.rs.h | ||
src/lib.rs | ||
.dir-locals.el |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
fn main() { | ||
let sources = vec!["src/lib.rs", "src/web.rs"]; | ||
let sources = vec!["src/lib.rs", "src/web.rs", "src/misc.rs"]; | ||
cxx_build::bridges(sources) | ||
// .file("src/source.cc") Code callable from Rust is in ../cxxsupport.cc | ||
.flag_if_supported("-std=c++17") | ||
.flag("-Isrc") | ||
.flag("-I../../..") | ||
.compile("settings"); | ||
|
||
// lib.rs is genertated an take carte of by parent Makefile | ||
println!("cargo:rerun-if-changed=src/misc.rs"); | ||
println!("cargo:rerun-if-changed=src/web.rs"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#[cxx::bridge(namespace = "pdns::rust::misc")] | ||
pub mod rustmisc { | ||
|
||
pub enum LogLevel { | ||
None, | ||
Normal, | ||
Detailed, | ||
} | ||
enum Priority { | ||
Absent = 0, | ||
Alert = 1, | ||
Critical = 2, | ||
Error = 3, | ||
Warning = 4, | ||
Notice = 5, | ||
Info = 6, | ||
Debug = 7, | ||
} | ||
struct KeyValue { | ||
key: String, | ||
value: String, | ||
} | ||
|
||
extern "C++" { | ||
type NetmaskGroup; | ||
type ComboAddress; | ||
type Logger; | ||
} | ||
|
||
unsafe extern "C++" { | ||
include!("bridge.hh"); | ||
fn qTypeStringToCode(name: &str) -> u16; | ||
fn isValidHostname(name: &str) -> bool; | ||
fn comboaddress(address: &str) -> UniquePtr<ComboAddress>; | ||
fn matches(nmg: &UniquePtr<NetmaskGroup>, address: &UniquePtr<ComboAddress>) -> bool; // match is a keyword | ||
fn withValue(logger: &SharedPtr<Logger>, key: &str, val: &str) -> SharedPtr<Logger>; | ||
fn log(logger: &SharedPtr<Logger>, prio: Priority, msg: &str, values: &Vec<KeyValue>); | ||
fn error( | ||
logger: &SharedPtr<Logger>, | ||
prio: Priority, | ||
err: &str, | ||
msg: &str, | ||
values: &Vec<KeyValue>, | ||
); | ||
} | ||
} | ||
|
Oops, something went wrong.