1
1
use std:: io;
2
2
3
- use crate :: PluginGuestInitError ;
4
-
5
- pub use self :: chipmunk:: plugin:: { bytesource_types, shared_types} ;
6
- use self :: shared_types:: { ConfigItem , ConfigSchemaItem , ConfigSchemaType , ConfigValue , Version } ;
3
+ pub use self :: chipmunk:: bytesource:: bytesource_types;
7
4
8
5
wasmtime:: component:: bindgen!( {
9
- path: "../plugins_api/wit/v_0 .1.0/ " ,
10
- world: "bytesource-plugin " ,
6
+ path: "../plugins_api/wit/v0 .1.0" ,
7
+ world: "chipmunk: bytesource/bytesource " ,
11
8
async : {
12
9
only_imports: [ ] ,
13
10
} ,
11
+ with: {
12
+ "chipmunk:shared/[email protected] " : crate :: v0_1_0
:: shared
:: logging
,
13
+ "chipmunk:shared/[email protected] " : crate :: v0_1_0
:: shared
:: shared_types
,
14
+ }
14
15
} ) ;
15
16
16
17
impl From < & stypes:: PluginByteSourceGeneralSettings > for bytesource_types:: SourceConfig {
@@ -19,7 +20,7 @@ impl From<&stypes::PluginByteSourceGeneralSettings> for bytesource_types::Source
19
20
// functionality to log the message from the plugins.
20
21
let current_log_level = log:: max_level ( ) . to_level ( ) . unwrap_or ( log:: Level :: Error ) ;
21
22
22
- use chipmunk :: plugin :: logging:: Level as PlugLevel ;
23
+ use crate :: v0_1_0 :: shared :: logging:: Level as PlugLevel ;
23
24
let level = match current_log_level {
24
25
log:: Level :: Error => PlugLevel :: Error ,
25
26
log:: Level :: Warn => PlugLevel :: Warn ,
@@ -32,93 +33,15 @@ impl From<&stypes::PluginByteSourceGeneralSettings> for bytesource_types::Source
32
33
}
33
34
}
34
35
35
- impl From < shared_types:: InitError > for PluginGuestInitError {
36
- fn from ( value : shared_types:: InitError ) -> Self {
37
- use shared_types:: InitError as E ;
38
- use PluginGuestInitError as GuestE ;
39
- match value {
40
- E :: Config ( msg) => GuestE :: Config ( msg) ,
41
- E :: Io ( msg) => GuestE :: IO ( msg) ,
42
- E :: Unsupported ( msg) => GuestE :: Unsupported ( msg) ,
43
- E :: Other ( msg) => GuestE :: Other ( msg) ,
44
- }
45
- }
46
- }
47
-
48
36
impl From < bytesource_types:: SourceError > for io:: Error {
49
37
fn from ( value : bytesource_types:: SourceError ) -> Self {
50
38
use bytesource_types:: SourceError as E ;
51
39
let msg = match value {
52
40
E :: Io ( msg) => format ! ( "IO Error from bytesoruce plugin. Error: {msg}" ) ,
53
- E :: Unsupported => String :: from ( "Unsupported Error from bytesource plugin" ) ,
41
+ E :: Unsupported ( msg ) => format ! ( "Unsupported Error from bytesource plugin: {msg} " ) ,
54
42
E :: Other ( msg) => format ! ( "Unknown Error from bytesoruce plugin. Error: {msg}" ) ,
55
43
} ;
56
44
57
45
io:: Error :: new ( io:: ErrorKind :: Other , msg)
58
46
}
59
47
}
60
-
61
- use stypes:: PluginConfigValue as HostConfValue ;
62
- impl From < HostConfValue > for ConfigValue {
63
- fn from ( value : HostConfValue ) -> Self {
64
- match value {
65
- HostConfValue :: Boolean ( val) => ConfigValue :: Boolean ( val) ,
66
- HostConfValue :: Integer ( val) => ConfigValue :: Integer ( val) ,
67
- HostConfValue :: Float ( val) => ConfigValue :: Float ( val) ,
68
- HostConfValue :: Text ( val) => ConfigValue :: Text ( val) ,
69
- HostConfValue :: Files ( val) => ConfigValue :: Files (
70
- val. into_iter ( )
71
- . map ( |p| p. to_string_lossy ( ) . to_string ( ) )
72
- . collect ( ) ,
73
- ) ,
74
- HostConfValue :: Directories ( val) => ConfigValue :: Directories (
75
- val. into_iter ( )
76
- . map ( |p| p. to_string_lossy ( ) . to_string ( ) )
77
- . collect ( ) ,
78
- ) ,
79
- HostConfValue :: Dropdown ( val) => ConfigValue :: Dropdown ( val) ,
80
- }
81
- }
82
- }
83
-
84
- impl From < stypes:: PluginConfigItem > for ConfigItem {
85
- fn from ( item : stypes:: PluginConfigItem ) -> Self {
86
- Self {
87
- id : item. id ,
88
- value : item. value . into ( ) ,
89
- }
90
- }
91
- }
92
-
93
- use stypes:: PluginConfigSchemaType as HostSchemaType ;
94
- use stypes:: SemanticVersion ;
95
- impl From < ConfigSchemaType > for HostSchemaType {
96
- fn from ( value : ConfigSchemaType ) -> Self {
97
- match value {
98
- ConfigSchemaType :: Boolean => HostSchemaType :: Boolean ,
99
- ConfigSchemaType :: Integer => HostSchemaType :: Integer ,
100
- ConfigSchemaType :: Float => HostSchemaType :: Float ,
101
- ConfigSchemaType :: Text => HostSchemaType :: Text ,
102
- ConfigSchemaType :: Directories => HostSchemaType :: Directories ,
103
- ConfigSchemaType :: Files ( exts) => HostSchemaType :: Files ( exts) ,
104
- ConfigSchemaType :: Dropdown ( items) => HostSchemaType :: Dropdown ( items) ,
105
- }
106
- }
107
- }
108
-
109
- impl From < ConfigSchemaItem > for stypes:: PluginConfigSchemaItem {
110
- fn from ( item : ConfigSchemaItem ) -> Self {
111
- Self {
112
- id : item. id ,
113
- title : item. title ,
114
- description : item. description ,
115
- input_type : item. input_type . into ( ) ,
116
- }
117
- }
118
- }
119
-
120
- impl From < Version > for SemanticVersion {
121
- fn from ( value : Version ) -> Self {
122
- Self :: new ( value. major , value. minor , value. patch )
123
- }
124
- }
0 commit comments