Skip to main content

Language

Enum Language 

Source
#[non_exhaustive]
pub enum Language {
Show 103 variants Rust, Ada, Agda, Asciidoc, Asm, Awk, Bash, Batch, C, CSharp, Caddy, Capnp, Cedar, CedarSchema, Clojure, CMake, Cobol, CommonLisp, Cpp, Css, D, Dart, DeviceTree, Diff, Dockerfile, Dot, Elisp, Elixir, Elm, Erlang, Fish, FSharp, Gleam, Glsl, Go, GraphQL, Groovy, Haskell, Hcl, Hlsl, Html, Idris, Ini, Java, JavaScript, Jinja2, Jq, Json, Julia, Kotlin, Lean, Lua, Markdown, Matlab, Meson, Nginx, Ninja, Nix, ObjectiveC, OCaml, Perl, Php, PostScript, PowerShell, Prolog, Python, Query, R, Rego, Rescript, Ron, Ruby, Scala, Scheme, Scss, Solidity, Sparql, Sql, SshConfig, Starlark, Styx, Svelte, Swift, Textproto, Thrift, TlaPlus, Toml, Tsx, TypeScript, Typst, Uiua, VisualBasic, Verilog, Vhdl, Vim, Vue, Wit, X86Asm, Xml, Yaml, Yuri, Zig, Zsh,
}
Expand description

Tree-sitter grammar identifier.

Each variant maps to an Arborium language slug via Language::slug. Variants are gated by the same lang-* cargo features as the grammar lookup table, so each build exposes the variants enabled for that build.

use dioxus_code::Language;
assert_eq!(Language::Rust.slug(), "rust");
assert_eq!(Language::from_slug("brainfuck"), None);

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Rust

Arborium slug "rust".

§

Ada

Available on crate feature lang-ada only.

Arborium slug "ada".

§

Agda

Available on crate feature lang-agda only.

Arborium slug "agda".

§

Asciidoc

Available on crate feature lang-asciidoc only.

Arborium slug "asciidoc".

§

Asm

Available on crate feature lang-asm only.

Arborium slug "asm".

§

Awk

Available on crate feature lang-awk only.

Arborium slug "awk".

§

Bash

Available on crate feature lang-bash only.

Arborium slug "bash".

§

Batch

Available on crate feature lang-batch only.

Arborium slug "batch".

§

C

Available on crate feature lang-c only.

Arborium slug "c".

§

CSharp

Available on crate feature lang-c-sharp only.

Arborium slug "c-sharp".

§

Caddy

Available on crate feature lang-caddy only.

Arborium slug "caddy".

§

Capnp

Available on crate feature lang-capnp only.

Arborium slug "capnp".

§

Cedar

Available on crate feature lang-cedar only.

Arborium slug "cedar".

§

CedarSchema

Available on crate feature lang-cedarschema only.

Arborium slug "cedarschema".

§

Clojure

Available on crate feature lang-clojure only.

Arborium slug "clojure".

§

CMake

Available on crate feature lang-cmake only.

Arborium slug "cmake".

§

Cobol

Available on crate feature lang-cobol only.

Arborium slug "cobol".

§

CommonLisp

Available on crate feature lang-commonlisp only.

Arborium slug "commonlisp".

§

Cpp

Available on crate feature lang-cpp only.

Arborium slug "cpp".

§

Css

Available on crate feature lang-css only.

Arborium slug "css".

§

D

Available on crate feature lang-d only.

Arborium slug "d".

§

Dart

Available on crate feature lang-dart only.

Arborium slug "dart".

§

DeviceTree

Available on crate feature lang-devicetree only.

Arborium slug "devicetree".

§

Diff

Available on crate feature lang-diff only.

Arborium slug "diff".

§

Dockerfile

Available on crate feature lang-dockerfile only.

Arborium slug "dockerfile".

§

Dot

Available on crate feature lang-dot only.

Arborium slug "dot".

§

Elisp

Available on crate feature lang-elisp only.

Arborium slug "elisp".

§

Elixir

Available on crate feature lang-elixir only.

Arborium slug "elixir".

§

Elm

Available on crate feature lang-elm only.

Arborium slug "elm".

§

Erlang

Available on crate feature lang-erlang only.

Arborium slug "erlang".

§

Fish

Available on crate feature lang-fish only.

Arborium slug "fish".

§

FSharp

Available on crate feature lang-fsharp only.

Arborium slug "fsharp".

§

Gleam

Available on crate feature lang-gleam only.

Arborium slug "gleam".

§

Glsl

Available on crate feature lang-glsl only.

Arborium slug "glsl".

§

Go

Available on crate feature lang-go only.

Arborium slug "go".

§

GraphQL

Available on crate feature lang-graphql only.

Arborium slug "graphql".

§

Groovy

Available on crate feature lang-groovy only.

Arborium slug "groovy".

§

Haskell

Available on crate feature lang-haskell only.

Arborium slug "haskell".

§

Hcl

Available on crate feature lang-hcl only.

Arborium slug "hcl".

§

Hlsl

Available on crate feature lang-hlsl only.

Arborium slug "hlsl".

§

Html

Available on crate feature lang-html only.

Arborium slug "html".

§

Idris

Available on crate feature lang-idris only.

Arborium slug "idris".

§

Ini

Available on crate feature lang-ini only.

Arborium slug "ini".

§

Java

Available on crate feature lang-java only.

Arborium slug "java".

§

JavaScript

Available on crate feature lang-javascript only.

Arborium slug "javascript".

§

Jinja2

Available on crate feature lang-jinja2 only.

Arborium slug "jinja2".

§

Jq

Available on crate feature lang-jq only.

Arborium slug "jq".

§

Json

Available on crate feature lang-json only.

Arborium slug "json".

§

Julia

Available on crate feature lang-julia only.

Arborium slug "julia".

§

Kotlin

Available on crate feature lang-kotlin only.

Arborium slug "kotlin".

§

Lean

Available on crate feature lang-lean only.

Arborium slug "lean".

§

Lua

Available on crate feature lang-lua only.

Arborium slug "lua".

§

Markdown

Available on crate feature lang-markdown only.

Arborium slug "markdown".

§

Matlab

Available on crate feature lang-matlab only.

Arborium slug "matlab".

§

Meson

Available on crate feature lang-meson only.

Arborium slug "meson".

§

Nginx

Available on crate feature lang-nginx only.

Arborium slug "nginx".

§

Ninja

Available on crate feature lang-ninja only.

Arborium slug "ninja".

§

Nix

Available on crate feature lang-nix only.

Arborium slug "nix".

§

ObjectiveC

Available on crate feature lang-objc only.

Arborium slug "objc".

§

OCaml

Available on crate feature lang-ocaml only.

Arborium slug "ocaml".

§

Perl

Available on crate feature lang-perl only.

Arborium slug "perl".

§

Php

Available on crate feature lang-php only.

Arborium slug "php".

§

PostScript

Available on crate feature lang-postscript only.

Arborium slug "postscript".

§

PowerShell

Available on crate feature lang-powershell only.

Arborium slug "powershell".

§

Prolog

Available on crate feature lang-prolog only.

Arborium slug "prolog".

§

Python

Available on crate feature lang-python only.

Arborium slug "python".

§

Query

Available on crate feature lang-query only.

Arborium slug "query".

§

R

Available on crate feature lang-r only.

Arborium slug "r".

§

Rego

Available on crate feature lang-rego only.

Arborium slug "rego".

§

Rescript

Available on crate feature lang-rescript only.

Arborium slug "rescript".

§

Ron

Available on crate feature lang-ron only.

Arborium slug "ron".

§

Ruby

Available on crate feature lang-ruby only.

Arborium slug "ruby".

§

Scala

Available on crate feature lang-scala only.

Arborium slug "scala".

§

Scheme

Available on crate feature lang-scheme only.

Arborium slug "scheme".

§

Scss

Available on crate feature lang-scss only.

Arborium slug "scss".

§

Solidity

Available on crate feature lang-solidity only.

Arborium slug "solidity".

§

Sparql

Available on crate feature lang-sparql only.

Arborium slug "sparql".

§

Sql

Available on crate feature lang-sql only.

Arborium slug "sql".

§

SshConfig

Available on crate feature lang-ssh-config only.

Arborium slug "ssh-config".

§

Starlark

Available on crate feature lang-starlark only.

Arborium slug "starlark".

§

Styx

Available on crate feature lang-styx only.

Arborium slug "styx".

§

Svelte

Available on crate feature lang-svelte only.

Arborium slug "svelte".

§

Swift

Available on crate feature lang-swift only.

Arborium slug "swift".

§

Textproto

Available on crate feature lang-textproto only.

Arborium slug "textproto".

§

Thrift

Available on crate feature lang-thrift only.

Arborium slug "thrift".

§

TlaPlus

Available on crate feature lang-tlaplus only.

Arborium slug "tlaplus".

§

Toml

Available on crate feature lang-toml only.

Arborium slug "toml".

§

Tsx

Available on crate feature lang-tsx only.

Arborium slug "tsx".

§

TypeScript

Available on crate feature lang-typescript only.

Arborium slug "typescript".

§

Typst

Available on crate feature lang-typst only.

Arborium slug "typst".

§

Uiua

Available on crate feature lang-uiua only.

Arborium slug "uiua".

§

VisualBasic

Available on crate feature lang-vb only.

Arborium slug "vb".

§

Verilog

Available on crate feature lang-verilog only.

Arborium slug "verilog".

§

Vhdl

Available on crate feature lang-vhdl only.

Arborium slug "vhdl".

§

Vim

Available on crate feature lang-vim only.

Arborium slug "vim".

§

Vue

Available on crate feature lang-vue only.

Arborium slug "vue".

§

Wit

Available on crate feature lang-wit only.

Arborium slug "wit".

§

X86Asm

Available on crate feature lang-x86asm only.

Arborium slug "x86asm".

§

Xml

Available on crate feature lang-xml only.

Arborium slug "xml".

§

Yaml

Available on crate feature lang-yaml only.

Arborium slug "yaml".

§

Yuri

Available on crate feature lang-yuri only.

Arborium slug "yuri".

§

Zig

Available on crate feature lang-zig only.

Arborium slug "zig".

§

Zsh

Available on crate feature lang-zsh only.

Arborium slug "zsh".

Implementations§

Source§

impl Language

Source

pub fn detect(input: &str) -> Option<Self>

Available on crate feature runtime only.

Best-effort detection from a path, filename, shebang, or file contents.

Wraps arborium::detect_language and maps the resulting slug into a Language variant, returning None when detection fails or the detected language’s grammar feature is disabled in this build.

Available with the runtime feature.

Source§

impl Language

Source

pub const ALL: &'static [Language]

Every variant compiled into this build, in declaration order.

Variants whose grammars are gated behind cargo features only appear here when the corresponding feature is enabled.

use dioxus_code::Language;
assert!(Language::ALL.contains(&Language::Rust));
Source

pub const fn slug(self) -> &'static str

Arborium slug for this language.

Source

pub fn from_slug(slug: &str) -> Option<Self>

Parse an Arborium slug into a Language.

Returns None for unknown slugs and for slugs whose grammar feature is disabled in this build.

Trait Implementations§

Source§

impl Clone for Language

Source§

fn clone(&self) -> Language

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Language

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Language

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Language

Source§

fn eq(&self, other: &Language) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Language

Source§

impl Eq for Language

Source§

impl StructuralPartialEq for Language

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> InitializeFromFunction<T> for T

Source§

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<Ret> SpawnIfAsync<(), Ret> for Ret

Source§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
Source§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

Source§

fn super_from(input: T) -> O

Convert from a type to another type.
Source§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

Source§

fn super_into(self) -> O

Convert from a type to another type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DependencyElement for T
where T: 'static + PartialEq + Clone,