Skip to main content

Lang

Enum Lang 

Source
pub enum Lang {
Show 19 variants Rust, TypeScript, JavaScript, Python, Go, Java, C, Cpp, Ruby, Shell, Sql, Html, Css, Json, Yaml, Toml, Markdown, Unknown, Other(u8),
}
Expand description

Programming language identifiers for CODE blocks.

Each variant maps to a single wire byte. The Unknown variant (0xFF) is used when the language is not in the predefined set. For truly unrecognized bytes from a newer encoder, Other(u8) preserves the raw value for forward compatibility.

┌──────┬────────────┐
│ Wire │ Language    │
├──────┼────────────┤
│ 0x01 │ Rust       │
│ 0x02 │ TypeScript │
│ 0x03 │ JavaScript │
│ 0x04 │ Python     │
│ 0x05 │ Go         │
│ 0x06 │ Java       │
│ 0x07 │ C          │
│ 0x08 │ Cpp        │
│ 0x09 │ Ruby       │
│ 0x0A │ Shell      │
│ 0x0B │ Sql        │
│ 0x0C │ Html       │
│ 0x0D │ Css        │
│ 0x0E │ Json       │
│ 0x0F │ Yaml       │
│ 0x10 │ Toml       │
│ 0x11 │ Markdown   │
│ 0xFF │ Unknown    │
└──────┴────────────┘

Lang is special compared to other enums in this module: it has an Other(u8) variant for forward compatibility, so it cannot use the wire_enum! macro and is implemented manually.

Variants§

§

Rust

§

TypeScript

§

JavaScript

§

Python

§

Go

§

Java

§

C

§

Cpp

§

Ruby

§

Shell

§

Sql

§

Html

§

Css

§

Json

§

Yaml

§

Toml

§

Markdown

§

Unknown

§

Other(u8)

Forward-compatible catch-all. Preserves the raw wire byte for language IDs this version doesn’t recognize.

Implementations§

Source§

impl Lang

Source

pub fn to_wire_byte(self) -> u8

Encode this variant as a single wire byte.

Source

pub fn from_wire_byte(value: u8) -> Self

Decode a wire byte into a Lang.

Known values map to named variants. Unrecognized values become Other(id) rather than an error, since new languages may be added without a spec revision.

Trait Implementations§

Source§

impl Clone for Lang

Source§

fn clone(&self) -> Lang

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Lang

Source§

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

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

impl PartialEq for Lang

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 Lang

Source§

impl Eq for Lang

Source§

impl StructuralPartialEq for Lang

Auto Trait Implementations§

§

impl Freeze for Lang

§

impl RefUnwindSafe for Lang

§

impl Send for Lang

§

impl Sync for Lang

§

impl Unpin for Lang

§

impl UnsafeUnpin for Lang

§

impl UnwindSafe for Lang

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, 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<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.