sfid 0.1.12

Distributed Snowflake ID generator with Redis-based auto machine ID allocation / 基于 Redis 自动分配机器号的分布式雪花 ID 生成器
Documentation
use std::io;

use thiserror::Error;

pub type Result<T, E = Error> = std::result::Result<T, E>;

#[derive(Debug, Error)]
pub enum Error {
  #[cfg(feature = "auto_pid")]
  #[error("Redis: {0}")]
  Redis(#[from] fred::error::Error),

  #[cfg(feature = "auto_pid")]
  #[error("No available PID, all {0} slots occupied")]
  NoAvailablePid(u32),

  #[cfg(feature = "auto_pid")]
  #[error("Machine ID: {0}")]
  OsId(#[from] &'static osid::Error),

  #[cfg(feature = "auto_pid")]
  #[error("Lock file: {0}")]
  LockFile(io::Error),
}