Skip to content

Use enums for languages and use it in Definition #15

@Boscop

Description

@Boscop
pub enum Detection {
    Filename(&'static str),
    Extension(&'static str),
    Shebang(&'static str),
    Heuristics(&'static str),
    Classifier(&'static str),
}

From the docs it's not clear which values this string can have!
It would be a nicer & more idiomatic & stable API if the set of possible languages was represented as an enum.
Then we could easily match on that, to map it to syntax highlighters, markdown codeblock-language-indicator-abbreviations etc.

And it would also be more ergonomic if Detection had separate fields for language and detection method. E.g.:

pub struct Detection {
  pub language: Language, // The new enum
  pub method: DetectionMethod, // Separate enum
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions