Skip to content

Commit

Permalink
update rust
Browse files Browse the repository at this point in the history
  • Loading branch information
ksyeo1010 committed Oct 16, 2023
1 parent 4cc3c7a commit 120cc8d
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 16 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/rust-codestyle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ jobs:
toolchain: stable
override: true

- name: Rust build binding
run: bash copy.sh && cargo build --verbose
working-directory: binding/rust

- name: Run clippy
run: cargo clippy -- -D warnings
working-directory: binding/rust
Expand Down Expand Up @@ -85,6 +89,10 @@ jobs:
profile: minimal
toolchain: stable
override: true

- name: Rust build binding
run: bash copy.sh && cargo build --verbose
working-directory: binding/rust

- name: Run clippy
run: cargo clippy -- -D warnings
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/rust-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ jobs:
profile: minimal
toolchain: stable
override: true

- name: Rust build binding
run: bash copy.sh && cargo build --verbose
working-directory: binding/rust

- name: Rust build micdemo
run: cargo build --verbose
Expand Down Expand Up @@ -89,6 +93,10 @@ jobs:
with:
toolchain: nightly
override: true

- name: Rust build binding
run: bash copy.sh && cargo build --verbose
working-directory: binding/rust

- name: Rust build micdemo
run: cargo build --verbose
Expand Down
18 changes: 10 additions & 8 deletions binding/rust/src/rhino.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ use libloading::os::unix::Symbol as RawSymbol;
use libloading::os::windows::Symbol as RawSymbol;

#[repr(C)]
struct CRhino {}
struct CRhino {
// Fields suggested by the Rustonomicon: https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs
_data: [u8; 0],
_marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>,
}

#[repr(C)]
#[derive(PartialEq, Clone, Debug)]
Expand Down Expand Up @@ -87,6 +91,7 @@ type PvGetErrorStackFn =
type PvFreeErrorStackFn = unsafe extern "C" fn(message_stack: *mut *mut c_char);
type PvSetSdkFn = unsafe extern "C" fn(sdk: *const c_char);


#[derive(PartialEq, Clone, Debug)]
pub enum RhinoErrorStatus {
LibraryError(PvStatus),
Expand Down Expand Up @@ -129,16 +134,13 @@ impl std::fmt::Display for RhinoError {
let mut message_string = String::new();
message_string.push_str(&format!("{} with status '{:?}'", self.message, self.status));

if self.message_stack.len() == 0 {
message_string.push_str(".");
write!(f, "{}", message_string)
} else {
message_string.push_str(":");
if !self.message_stack.is_empty() {
message_string.push(':');
for x in 0..self.message_stack.len() {
message_string.push_str(&format!(" [{}] {}\n", x, self.message_stack[x]))
}
write!(f, "{}", message_string)
};
}
write!(f, "{}", message_string)
}
}

Expand Down
4 changes: 1 addition & 3 deletions demo/rust/filedemo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion demo/rust/filedemo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ chrono = "0.4.23"
clap = "3.2.3"
hound = "3.4.0"
itertools = "0.10.3"
pv_rhino = "=2.2.1"
pv_rhino = { path = "../../../binding/rust" }
4 changes: 1 addition & 3 deletions demo/rust/micdemo/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion demo/rust/micdemo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ ctrlc = "3.2.2"
hound = "3.4.0"
itertools = "0.10.3"
pv_recorder = "=1.2.1"
pv_rhino = "=2.2.1"
pv_rhino = { path = "../../../binding/rust" }
1 change: 1 addition & 0 deletions resources/.lint/spell-check/dict.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ rhinomicdemo
rhinotestapp
rodio
rosado
Rustonomicon
RTLD
seumateu
shōmei
Expand Down

0 comments on commit 120cc8d

Please sign in to comment.