| 1 | macro_rules! string_enum { |
| 2 | ($name:ident { $($variant:ident = $text:literal),+ $(,)? }) => { |
| 3 | impl $name { |
| 4 | pub const fn as_str(self) -> &'static str { |
| 5 | match self { |
| 6 | $(Self::$variant => $text),+ |
| 7 | } |
| 8 | } |
| 9 | } |
| 10 | |
| 11 | impl std::str::FromStr for $name { |
| 12 | type Err = crate::error::Error; |
| 13 | |
| 14 | fn from_str(s: &str) -> std::result::Result<Self, Self::Err> { |
| 15 | match s { |
| 16 | $($text => Ok(Self::$variant),)+ |
| 17 | other => Err(crate::error::Error::Invalid(format!( |
| 18 | "{}: {other:?}", |
| 19 | stringify!($name) |
| 20 | ))), |
| 21 | } |
| 22 | } |
| 23 | } |
| 24 | }; |
| 25 | } |
| 26 | |
| 27 | pub mod alerts; |
| 28 | pub mod audit; |
| 29 | pub mod authz; |
| 30 | pub mod avatar; |
| 31 | pub mod ci; |
| 32 | pub mod config; |
| 33 | pub mod error; |
| 34 | pub mod issue_refs; |
| 35 | pub mod issues; |
| 36 | pub mod lfs_token; |
| 37 | pub mod mail; |
| 38 | pub mod merge_queue; |
| 39 | pub mod mirrors; |
| 40 | pub mod model; |
| 41 | pub mod names; |
| 42 | pub mod notifications; |
| 43 | pub mod password; |
| 44 | pub mod protection; |
| 45 | pub mod pulls; |
| 46 | pub mod raw_token; |
| 47 | pub mod reactions; |
| 48 | pub mod releases; |
| 49 | pub mod reviews; |
| 50 | pub mod secret; |
| 51 | pub mod server_settings; |
| 52 | pub mod signed_token; |
| 53 | pub mod store; |
| 54 | pub mod suggestions; |
| 55 | pub mod time; |
| 56 | pub mod token; |
| 57 | pub mod totp; |
| 58 | pub mod tz; |
| 59 | pub mod webhooks; |
| 60 | |
| 61 | pub use audit::*; |
| 62 | pub use authz::{Action, Denied, authorize}; |
| 63 | pub use config::{Config, Registration}; |
| 64 | pub use error::{Error, Result}; |
| 65 | pub use issues::*; |
| 66 | pub use model::*; |
| 67 | pub use notifications::*; |
| 68 | pub use pulls::*; |
| 69 | pub use reactions::{Reaction, ReactionMap, ReactionSummary, ReactionTarget}; |
| 70 | pub use reviews::*; |
| 71 | pub use store::Store; |
| 72 | pub use store::edit_history_read::{EditTarget, EditVersion}; |