[][src]Enum tokei::LanguageType

#[non_exhaustive]pub enum LanguageType {
    Abap,
    ActionScript,
    Ada,
    Agda,
    Alex,
    Alloy,
    Arduino,
    Asn1,
    Asp,
    AspNet,
    Assembly,
    AssemblyGAS,
    AutoHotKey,
    Autoconf,
    Automake,
    Bash,
    Batch,
    BrightScript,
    C,
    CHeader,
    CMake,
    CSharp,
    CShell,
    Cabal,
    Cassius,
    Ceylon,
    Clojure,
    ClojureC,
    ClojureScript,
    Cobol,
    CoffeeScript,
    Cogent,
    ColdFusion,
    ColdFusionScript,
    Coq,
    Cpp,
    CppHeader,
    Crystal,
    Css,
    D,
    Dart,
    DeviceTree,
    Dhall,
    Dockerfile,
    DotNetResource,
    DreamMaker,
    Dust,
    Edn,
    Elisp,
    Elixir,
    Elm,
    Elvish,
    EmacsDevEnv,
    Emojicode,
    Erlang,
    FEN,
    FSharp,
    Fish,
    FlatBuffers,
    Forth,
    FortranLegacy,
    FortranModern,
    FreeMarker,
    Fstar,
    Futhark,
    GDB,
    GdScript,
    Gherkin,
    Glsl,
    Go,
    Gohtml,
    Graphql,
    Groovy,
    Hamlet,
    Handlebars,
    Happy,
    Haskell,
    Haxe,
    Hcl,
    Headache,
    Hex,
    Hlsl,
    HolyC,
    Html,
    Idris,
    Ini,
    IntelHex,
    Isabelle,
    Jai,
    Java,
    JavaScript,
    Json,
    Jsx,
    Julia,
    Julius,
    Jupyter,
    K,
    KakouneScript,
    Kotlin,
    LLVM,
    Lean,
    Less,
    LinkerScript,
    Liquid,
    Lisp,
    Logtalk,
    Lua,
    Lucius,
    Madlang,
    Makefile,
    Markdown,
    Meson,
    Mint,
    ModuleDef,
    MoonScript,
    MsBuild,
    Mustache,
    Nim,
    Nix,
    NotQuitePerl,
    OCaml,
    ObjectiveC,
    ObjectiveCpp,
    Odin,
    OpenType,
    Org,
    Oz,
    PSL,
    Pan,
    Pascal,
    Perl,
    Perl6,
    Pest,
    Php,
    Polly,
    Pony,
    PostCss,
    PowerShell,
    Processing,
    Prolog,
    Protobuf,
    PureScript,
    Python,
    Q,
    Qcl,
    Qml,
    R,
    RON,
    RPMSpecfile,
    Racket,
    Rakefile,
    Razor,
    ReStructuredText,
    Renpy,
    Ruby,
    RubyHtml,
    Rust,
    SRecode,
    Sass,
    Scala,
    Scheme,
    Scons,
    Sh,
    Sml,
    Solidity,
    SpecmanE,
    Spice,
    Sql,
    Stratego,
    Svelte,
    Svg,
    Swift,
    Swig,
    SystemVerilog,
    Tcl,
    Tex,
    Text,
    Thrift,
    Toml,
    Tsx,
    Twig,
    TypeScript,
    UnrealDeveloperMarkdown,
    UnrealPlugin,
    UnrealProject,
    UnrealScript,
    UnrealShader,
    UnrealShaderHeader,
    UrWeb,
    UrWebProject,
    VB6,
    VBScript,
    Vala,
    Velocity,
    Verilog,
    VerilogArgsFile,
    Vhdl,
    VimScript,
    VisualBasic,
    VisualStudioProject,
    VisualStudioSolution,
    Vue,
    WebAssembly,
    Wolfram,
    XSL,
    Xaml,
    XcodeConfig,
    Xml,
    Xtend,
    Yaml,
    Zig,
    Zsh,
}

Represents a individual programming language. Can be used to provide information about the language, such as multi line comments, single line comments, string literal syntax, whether a given language allows nesting comments.

Variants (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.
Abap
ActionScript
Ada
Agda
Alex
Alloy
Arduino
Asn1
Asp
AspNet
Assembly
AssemblyGAS
AutoHotKey
Autoconf
Automake
Bash
Batch
BrightScript
C
CHeader
CMake
CSharp
CShell
Cabal
Cassius
Ceylon
Clojure
ClojureC
ClojureScript
Cobol
CoffeeScript
Cogent
ColdFusion
ColdFusionScript
Coq
Cpp
CppHeader
Crystal
Css
D
Dart
DeviceTree
Dhall
Dockerfile
DotNetResource
DreamMaker
Dust
Edn
Elisp
Elixir
Elm
Elvish
EmacsDevEnv
Emojicode
Erlang
FEN
FSharp
Fish
FlatBuffers
Forth
FortranLegacy
FortranModern
FreeMarker
Fstar
Futhark
GDB
GdScript
Gherkin
Glsl
Go
Gohtml
Graphql
Groovy
Hamlet
Handlebars
Happy
Haskell
Haxe
Hcl
Headache
Hex
Hlsl
HolyC
Html
Idris
Ini
IntelHex
Isabelle
Jai
Java
JavaScript
Json
Jsx
Julia
Julius
Jupyter
K
KakouneScript
Kotlin
LLVM
Lean
Less
LinkerScript
Liquid
Lisp
Logtalk
Lua
Lucius
Madlang
Makefile
Markdown
Meson
Mint
ModuleDef
MoonScript
MsBuild
Mustache
Nim
Nix
NotQuitePerl
OCaml
ObjectiveC
ObjectiveCpp
Odin
OpenType
Org
Oz
PSL
Pan
Pascal
Perl
Perl6
Pest
Php
Polly
Pony
PostCss
PowerShell
Processing
Prolog
Protobuf
PureScript
Python
Q
Qcl
Qml
R
RON
RPMSpecfile
Racket
Rakefile
Razor
ReStructuredText
Renpy
Ruby
RubyHtml
Rust
SRecode
Sass
Scala
Scheme
Scons
Sh
Sml
Solidity
SpecmanE
Spice
Sql
Stratego
Svelte
Svg
Swift
Swig
SystemVerilog
Tcl
Tex
Text
Thrift
Toml
Tsx
Twig
TypeScript
UnrealDeveloperMarkdown
UnrealPlugin
UnrealProject
UnrealScript
UnrealShader
UnrealShaderHeader
UrWeb
UrWebProject
VB6
VBScript
Vala
Velocity
Verilog
VerilogArgsFile
Vhdl
VimScript
VisualBasic
VisualStudioProject
VisualStudioSolution
Vue
WebAssembly
Wolfram
XSL
Xaml
XcodeConfig
Xml
Xtend
Yaml
Zig
Zsh

Implementations

impl LanguageType[src]

pub fn name(self) -> &'static str[src]

Returns the display name of a language.

let bash = LanguageType::Bash;

assert_eq!(bash.name(), "BASH");

pub fn is_literate(self) -> bool[src]

Returns whether the language is "literate", meaning that it considered to primarily be documentation and is counted primarily as comments rather than procedural code.

pub fn list() -> &'static [Self][src]

Provides every variant in a Vec

pub fn line_comments(self) -> &'static [&'static str][src]

Returns the single line comments of a language.

use tokei::LanguageType;
let lang = LanguageType::Rust;
assert_eq!(lang.line_comments(), &["//"]);

pub fn multi_line_comments(self) -> &'static [(&'static str, &'static str)][src]

Returns the single line comments of a language.

use tokei::LanguageType;
let lang = LanguageType::Rust;
assert_eq!(lang.multi_line_comments(), &[("/*", "*/")]);

pub fn allows_nested(self) -> bool[src]

Returns whether the language allows nested multi line comments.

use tokei::LanguageType;
let lang = LanguageType::Rust;
assert!(lang.allows_nested());

pub fn nested_comments(self) -> &'static [(&'static str, &'static str)][src]

Returns what nested comments the language has. (Currently only D has any of this type.)

use tokei::LanguageType;
let lang = LanguageType::D;
assert_eq!(lang.nested_comments(), &[("/+", "+/")]);

pub fn quotes(self) -> &'static [(&'static str, &'static str)][src]

Returns the quotes of a language.

use tokei::LanguageType;
let lang = LanguageType::C;
assert_eq!(lang.quotes(), &[("\"", "\"")]);

pub fn verbatim_quotes(self) -> &'static [(&'static str, &'static str)][src]

Returns the verbatim quotes of a language.

use tokei::LanguageType;
let lang = LanguageType::CSharp;
assert_eq!(lang.verbatim_quotes(), &[("@\"", "\"")]);

pub fn doc_quotes(self) -> &'static [(&'static str, &'static str)][src]

Returns the doc quotes of a language.

use tokei::LanguageType;
let lang = LanguageType::Python;
assert_eq!(lang.doc_quotes(), &[("\"\"\"", "\"\"\""), ("'''", "'''")]);

pub fn shebangs(self) -> &'static [&'static str][src]

Returns the shebang of a language.

use tokei::LanguageType;
let lang = LanguageType::Bash;
assert_eq!(lang.shebangs(), &["#!/bin/bash"]);

pub fn important_syntax(self) -> &'static [&'static str][src]

Returns the parts of syntax that determines whether tokei can skip large parts of analysis.

pub fn from_path<P: AsRef<Path>>(entry: P, _config: &Config) -> Option<Self>[src]

Get language from a file path. May open and read the file.

use tokei::{Config, LanguageType};

let rust = LanguageType::from_path("./main.rs", &Config::default());

assert_eq!(rust, Some(LanguageType::Rust));

pub fn from_file_extension(extension: &str) -> Option<Self>[src]

Get language from a file extension.

use tokei::LanguageType;

let rust = LanguageType::from_file_extension("rs");

assert_eq!(rust, Some(LanguageType::Rust));

pub fn from_mime(mime: &str) -> Option<Self>[src]

Get language from its MIME type if available.

use tokei::LanguageType;

let lang = LanguageType::from_mime("application/javascript");

assert_eq!(lang, Some(LanguageType::JavaScript));

pub fn from_shebang<P: AsRef<Path>>(entry: P) -> Option<Self>[src]

Get language from a shebang. May open and read the file.

use tokei::LanguageType;

let rust = LanguageType::from_shebang("./main.rs");

assert_eq!(rust, Some(LanguageType::Rust));

impl LanguageType[src]

pub fn parse(
    self,
    path: PathBuf,
    config: &Config
) -> Result<Report, (Error, PathBuf)>
[src]

Parses a given Path using the LanguageType. Returning Report on success and giving back ownership of PathBuf on error.

pub fn parse_from_str<A: AsRef<str>>(
    self,
    text: A,
    config: &Config
) -> CodeStats
[src]

Parses the text provided as the given LanguageType.

pub fn parse_from_slice<A: AsRef<[u8]>>(
    self,
    text: A,
    config: &Config
) -> CodeStats
[src]

Parses the bytes provided as the given LanguageType.

Trait Implementations

impl Clone for LanguageType[src]

impl Copy for LanguageType[src]

impl Debug for LanguageType[src]

impl<'de> Deserialize<'de> for LanguageType[src]

impl Display for LanguageType[src]

impl Eq for LanguageType[src]

impl<'a> From<&'a LanguageType> for Cow<'a, LanguageType>[src]

impl<'a> From<LanguageType> for Cow<'a, LanguageType>[src]

impl FromStr for LanguageType[src]

type Err = &'static str

The associated error which can be returned from parsing.

impl Hash for LanguageType[src]

impl Ord for LanguageType[src]

impl PartialEq<LanguageType> for LanguageType[src]

impl PartialOrd<LanguageType> for LanguageType[src]

impl Serialize for LanguageType[src]

impl StructuralEq for LanguageType[src]

impl StructuralPartialEq for LanguageType[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.