-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move some constants from bridge to ffi
- Loading branch information
Showing
7 changed files
with
47 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ path = "src/main.rs" | |
|
||
[dependencies] | ||
cbindgen = "0.20.0" | ||
env_logger = "0.10.0" |
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,27 +1,2 @@ | ||
pub const ENTRY_TYPE_FILE: u8 = 1; | ||
pub const ENTRY_TYPE_DIRECTORY: u8 = 2; | ||
|
||
pub const ACCESS_MODE_BLIND: u8 = 0; | ||
pub const ACCESS_MODE_READ: u8 = 1; | ||
pub const ACCESS_MODE_WRITE: u8 = 2; | ||
|
||
pub const NETWORK_EVENT_PROTOCOL_VERSION_MISMATCH: u8 = 0; | ||
pub const NETWORK_EVENT_PEER_SET_CHANGE: u8 = 1; | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use ouisync_lib::AccessMode; | ||
|
||
#[test] | ||
fn access_mode_constants() { | ||
for (mode, num) in [ | ||
(AccessMode::Blind, ACCESS_MODE_BLIND), | ||
(AccessMode::Read, ACCESS_MODE_READ), | ||
(AccessMode::Write, ACCESS_MODE_WRITE), | ||
] { | ||
assert_eq!(u8::from(mode), num); | ||
assert_eq!(AccessMode::try_from(num).unwrap(), mode); | ||
} | ||
} | ||
} |
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,33 @@ | ||
use ouisync_lib::EntryType; | ||
|
||
pub const ENTRY_TYPE_FILE: u8 = 1; | ||
pub const ENTRY_TYPE_DIRECTORY: u8 = 2; | ||
|
||
pub const ACCESS_MODE_BLIND: u8 = 0; | ||
pub const ACCESS_MODE_READ: u8 = 1; | ||
pub const ACCESS_MODE_WRITE: u8 = 2; | ||
|
||
pub(crate) fn entry_type_to_num(entry_type: EntryType) -> u8 { | ||
match entry_type { | ||
EntryType::File => ENTRY_TYPE_FILE, | ||
EntryType::Directory => ENTRY_TYPE_DIRECTORY, | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use ouisync_lib::AccessMode; | ||
|
||
#[test] | ||
fn access_mode_constants() { | ||
for (mode, num) in [ | ||
(AccessMode::Blind, ACCESS_MODE_BLIND), | ||
(AccessMode::Read, ACCESS_MODE_READ), | ||
(AccessMode::Write, ACCESS_MODE_WRITE), | ||
] { | ||
assert_eq!(u8::from(mode), num); | ||
assert_eq!(AccessMode::try_from(num).unwrap(), mode); | ||
} | ||
} | ||
} |
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