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

Arborium slug "ada".

§

Agda

Arborium slug "agda".

§

Asciidoc

Arborium slug "asciidoc".

§

Asm

Arborium slug "asm".

§

Awk

Arborium slug "awk".

§

Bash

Arborium slug "bash".

§

Batch

Arborium slug "batch".

§

C

Arborium slug "c".

§

CSharp

Arborium slug "c-sharp".

§

Caddy

Arborium slug "caddy".

§

Capnp

Arborium slug "capnp".

§

Cedar

Arborium slug "cedar".

§

CedarSchema

Arborium slug "cedarschema".

§

Clojure

Arborium slug "clojure".

§

CMake

Arborium slug "cmake".

§

Cobol

Arborium slug "cobol".

§

CommonLisp

Arborium slug "commonlisp".

§

Cpp

Arborium slug "cpp".

§

Css

Arborium slug "css".

§

D

Arborium slug "d".

§

Dart

Arborium slug "dart".

§

DeviceTree

Arborium slug "devicetree".

§

Diff

Arborium slug "diff".

§

Dockerfile

Arborium slug "dockerfile".

§

Dot

Arborium slug "dot".

§

Elisp

Arborium slug "elisp".

§

Elixir

Arborium slug "elixir".

§

Elm

Arborium slug "elm".

§

Erlang

Arborium slug "erlang".

§

Fish

Arborium slug "fish".

§

FSharp

Arborium slug "fsharp".

§

Gleam

Arborium slug "gleam".

§

Glsl

Arborium slug "glsl".

§

Go

Arborium slug "go".

§

GraphQL

Arborium slug "graphql".

§

Groovy

Arborium slug "groovy".

§

Haskell

Arborium slug "haskell".

§

Hcl

Arborium slug "hcl".

§

Hlsl

Arborium slug "hlsl".

§

Html

Arborium slug "html".

§

Idris

Arborium slug "idris".

§

Ini

Arborium slug "ini".

§

Java

Arborium slug "java".

§

JavaScript

Arborium slug "javascript".

§

Jinja2

Arborium slug "jinja2".

§

Jq

Arborium slug "jq".

§

Json

Arborium slug "json".

§

Julia

Arborium slug "julia".

§

Kotlin

Arborium slug "kotlin".

§

Lean

Arborium slug "lean".

§

Lua

Arborium slug "lua".

§

Markdown

Arborium slug "markdown".

§

Matlab

Arborium slug "matlab".

§

Meson

Arborium slug "meson".

§

Nginx

Arborium slug "nginx".

§

Ninja

Arborium slug "ninja".

§

Nix

Arborium slug "nix".

§

ObjectiveC

Arborium slug "objc".

§

OCaml

Arborium slug "ocaml".

§

Perl

Arborium slug "perl".

§

Php

Arborium slug "php".

§

PostScript

Arborium slug "postscript".

§

PowerShell

Arborium slug "powershell".

§

Prolog

Arborium slug "prolog".

§

Python

Arborium slug "python".

§

Query

Arborium slug "query".

§

R

Arborium slug "r".

§

Rego

Arborium slug "rego".

§

Rescript

Arborium slug "rescript".

§

Ron

Arborium slug "ron".

§

Ruby

Arborium slug "ruby".

§

Scala

Arborium slug "scala".

§

Scheme

Arborium slug "scheme".

§

Scss

Arborium slug "scss".

§

Solidity

Arborium slug "solidity".

§

Sparql

Arborium slug "sparql".

§

Sql

Arborium slug "sql".

§

SshConfig

Arborium slug "ssh-config".

§

Starlark

Arborium slug "starlark".

§

Styx

Arborium slug "styx".

§

Svelte

Arborium slug "svelte".

§

Swift

Arborium slug "swift".

§

Textproto

Arborium slug "textproto".

§

Thrift

Arborium slug "thrift".

§

TlaPlus

Arborium slug "tlaplus".

§

Toml

Arborium slug "toml".

§

Tsx

Arborium slug "tsx".

§

TypeScript

Arborium slug "typescript".

§

Typst

Arborium slug "typst".

§

Uiua

Arborium slug "uiua".

§

VisualBasic

Arborium slug "vb".

§

Verilog

Arborium slug "verilog".

§

Vhdl

Arborium slug "vhdl".

§

Vim

Arborium slug "vim".

§

Vue

Arborium slug "vue".

§

Wit

Arborium slug "wit".

§

X86Asm

Arborium slug "x86asm".

§

Xml

Arborium slug "xml".

§

Yaml

Arborium slug "yaml".

§

Yuri

Arborium slug "yuri".

§

Zig

Arborium slug "zig".

§

Zsh

Arborium slug "zsh".

Implementations§

Source§

impl Language

Source

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

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<Language>

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<(), Error>

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

impl Hash for Language

Source§

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

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,