You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

lib.rs 949 B

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
12345678910111213141516171819202122232425262728293031323334353637
  1. mod idgen;
  2. #[macro_use]
  3. // extern crate lazy_static;
  4. extern crate libc;
  5. use libc::{c_char, uint32_t};
  6. use std::ffi::{CStr, CString};
  7. use std::str;
  8. pub use idgen::*;
  9. // #[export_name = "SetIdGenerator"]
  10. #[no_mangle]
  11. pub extern "C" fn SetIdGenerator(options: IdGeneratorOptions) {
  12. YitIdHelper::SetIdGenerator(options);
  13. }
  14. #[no_mangle]
  15. pub extern "C" fn SetOptions(workerId: u32, workerIdBitLength: u8, seqBitLength: u8) {
  16. let mut options = IdGeneratorOptions::New(1);
  17. options.WorkerIdBitLength = workerIdBitLength;
  18. options.SeqBitLength = seqBitLength;
  19. YitIdHelper::SetIdGenerator(options);
  20. }
  21. #[no_mangle]
  22. pub extern "C" fn SetWorkerId(workerId: u32) {
  23. YitIdHelper::SetWorkerId(workerId);
  24. }
  25. #[no_mangle]
  26. pub extern "C" fn NextId() -> i64 {
  27. YitIdHelper::NextId()
  28. }
  29. // build-win-x64: cargo build --release
  30. // build-linux-x64: cargo build --target x86_64-unknown-linux-musl --release