2020-01-02 15:13:47 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2018-11-29 22:03:00 -05:00
|
|
|
|
2019-08-26 17:02:34 -04:00
|
|
|
// Warning! The values in this enum are duplicated in js/compiler.ts
|
|
|
|
// Update carefully!
|
2020-05-18 06:59:29 -04:00
|
|
|
use serde::Serialize;
|
2020-06-19 06:27:15 -04:00
|
|
|
use serde::Serializer;
|
2020-05-18 06:59:29 -04:00
|
|
|
|
2019-08-26 17:02:34 -04:00
|
|
|
#[allow(non_camel_case_types)]
|
2020-06-19 06:27:15 -04:00
|
|
|
#[repr(i32)]
|
|
|
|
#[derive(Clone, Copy, PartialEq, Debug)]
|
2019-08-26 17:02:34 -04:00
|
|
|
pub enum MediaType {
|
|
|
|
JavaScript = 0,
|
2019-10-02 10:46:36 -04:00
|
|
|
JSX = 1,
|
|
|
|
TypeScript = 2,
|
|
|
|
TSX = 3,
|
|
|
|
Json = 4,
|
2019-11-14 08:31:39 -05:00
|
|
|
Wasm = 5,
|
|
|
|
Unknown = 6,
|
2019-08-26 17:02:34 -04:00
|
|
|
}
|
|
|
|
|
2020-06-19 06:27:15 -04:00
|
|
|
impl Serialize for MediaType {
|
|
|
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
|
|
where
|
|
|
|
S: Serializer,
|
|
|
|
{
|
|
|
|
let value: i32 = match self {
|
|
|
|
MediaType::JavaScript => 0 as i32,
|
|
|
|
MediaType::JSX => 1 as i32,
|
|
|
|
MediaType::TypeScript => 2 as i32,
|
|
|
|
MediaType::TSX => 3 as i32,
|
|
|
|
MediaType::Json => 4 as i32,
|
|
|
|
MediaType::Wasm => 5 as i32,
|
|
|
|
MediaType::Unknown => 6 as i32,
|
|
|
|
};
|
|
|
|
Serialize::serialize(&value, serializer)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-26 17:02:34 -04:00
|
|
|
pub fn enum_name_media_type(mt: MediaType) -> &'static str {
|
|
|
|
match mt {
|
|
|
|
MediaType::JavaScript => "JavaScript",
|
2019-10-02 10:46:36 -04:00
|
|
|
MediaType::JSX => "JSX",
|
2019-08-26 17:02:34 -04:00
|
|
|
MediaType::TypeScript => "TypeScript",
|
2019-10-02 10:46:36 -04:00
|
|
|
MediaType::TSX => "TSX",
|
2019-08-26 17:02:34 -04:00
|
|
|
MediaType::Json => "Json",
|
2019-11-14 08:31:39 -05:00
|
|
|
MediaType::Wasm => "Wasm",
|
2019-08-26 17:02:34 -04:00
|
|
|
MediaType::Unknown => "Unknown",
|
|
|
|
}
|
|
|
|
}
|
2019-11-13 10:35:56 -05:00
|
|
|
|
|
|
|
// Warning! The values in this enum are duplicated in js/compiler.ts
|
|
|
|
// Update carefully!
|
|
|
|
#[allow(non_camel_case_types)]
|
2020-06-19 06:27:15 -04:00
|
|
|
#[repr(i32)]
|
2019-11-13 10:35:56 -05:00
|
|
|
#[derive(Clone, Copy, PartialEq, Debug)]
|
|
|
|
pub enum CompilerRequestType {
|
|
|
|
Compile = 0,
|
2020-07-08 05:26:39 -04:00
|
|
|
Transpile = 1,
|
|
|
|
Bundle = 2,
|
|
|
|
RuntimeCompile = 3,
|
|
|
|
RuntimeBundle = 4,
|
|
|
|
RuntimeTranspile = 5,
|
2020-06-19 06:27:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Serialize for CompilerRequestType {
|
|
|
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
|
|
where
|
|
|
|
S: Serializer,
|
|
|
|
{
|
|
|
|
let value: i32 = match self {
|
|
|
|
CompilerRequestType::Compile => 0 as i32,
|
2020-07-08 05:26:39 -04:00
|
|
|
CompilerRequestType::Transpile => 1 as i32,
|
|
|
|
CompilerRequestType::Bundle => 2 as i32,
|
|
|
|
CompilerRequestType::RuntimeCompile => 3 as i32,
|
|
|
|
CompilerRequestType::RuntimeBundle => 4 as i32,
|
|
|
|
CompilerRequestType::RuntimeTranspile => 5 as i32,
|
2020-06-19 06:27:15 -04:00
|
|
|
};
|
|
|
|
Serialize::serialize(&value, serializer)
|
|
|
|
}
|
2019-11-13 10:35:56 -05:00
|
|
|
}
|