MCPcopy Create free account
hub / github.com/Houseofmvps/codesight / struct_orm

Function struct_orm

plugins/ast/rust/src/lib.rs:366–381  ·  view source on GitHub ↗

Identify the ORM from a struct's derives/attributes (else "unknown").

(attrs: &[Attribute])

Source from the content-addressed store, hash-verified

364
365/// Identify the ORM from a struct's derives/attributes (else "unknown").
366fn 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.
384fn derives(attrs: &[Attribute]) -> Vec<String> {

Callers 1

extract_schemasFunction · 0.85

Calls 1

derivesFunction · 0.85

Tested by

no test coverage detected