Identify the ORM from a struct's derives/attributes (else "unknown").
(attrs: &[Attribute])
| 364 | |
| 365 | /// Identify the ORM from a struct's derives/attributes (else "unknown"). |
| 366 | fn struct_orm(attrs: &[Attribute]) -> &'static str { |
| 367 | let derives = derives(attrs); |
| 368 | let derived = |name: &str| derives.iter().any(|derive| derive == name); |
| 369 | |
| 370 | if derived("DeriveEntityModel") || attrs.iter().any(|attr| attr.path().is_ident("sea_orm")) { |
| 371 | "sea-orm" |
| 372 | } else if derived("Queryable") || derived("Insertable") || derived("Selectable") |
| 373 | || derived("Identifiable") |
| 374 | { |
| 375 | "diesel" |
| 376 | } else if derived("FromRow") { |
| 377 | "sqlx" |
| 378 | } else { |
| 379 | "unknown" |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | /// Collect the identifiers listed in every `#[derive(...)]` on an item. |
| 384 | fn derives(attrs: &[Attribute]) -> Vec<String> { |
no test coverage detected