File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -3,16 +3,19 @@ use brack_pdk_rs::metadata::Metadata;
3
3
use document:: metadata_document;
4
4
use extism_pdk:: { plugin_fn, FnResult , Json } ;
5
5
use stmt:: metadata_stmt;
6
+ use text:: metadata_text;
6
7
7
8
pub mod document;
8
9
pub mod bold;
9
10
pub mod stmt;
11
+ pub mod text;
10
12
11
13
#[ plugin_fn]
12
14
pub fn get_metadata ( ) -> FnResult < Json < Vec < Metadata > > > {
13
15
let mut metadata = Vec :: new ( ) ;
14
16
metadata. push ( metadata_bold ( ) ) ;
15
17
metadata. push ( metadata_document ( ) ) ;
16
18
metadata. push ( metadata_stmt ( ) ) ;
19
+ metadata. push ( metadata_text ( ) ) ;
17
20
Ok ( Json ( metadata) )
18
21
}
Original file line number Diff line number Diff line change
1
+ use brack_pdk_rs:: { metadata:: Metadata , types:: Type , values:: Value } ;
2
+ use extism_pdk:: { plugin_fn, FnResult , Json , WithReturnCode } ;
3
+
4
+ pub ( crate ) fn metadata_text ( ) -> Metadata {
5
+ Metadata {
6
+ command_name : "text" . to_string ( ) ,
7
+ call_name : "text" . to_string ( ) ,
8
+ argument_types : vec ! [ ( "text" . to_string( ) , Type :: TInline ) ] ,
9
+ return_type : Type :: TInline ,
10
+ }
11
+ }
12
+
13
+ #[ plugin_fn]
14
+ pub fn text ( Json ( args) : Json < Vec < Value > > ) -> FnResult < String > {
15
+ if args. len ( ) != 1 {
16
+ return Err ( WithReturnCode :: new ( anyhow:: anyhow!( "text failed" ) , 1 ) ) ;
17
+ }
18
+ let text = match & args[ 0 ] {
19
+ Value :: Text ( t) => t,
20
+ _ => {
21
+ return Err ( WithReturnCode :: new (
22
+ anyhow:: anyhow!( "text must be Value::Text" ) ,
23
+ 1 ,
24
+ ) )
25
+ }
26
+ } ;
27
+ Ok ( format ! ( "{{\" t\" : \" Str\" , \" c\" : \" {}\" }}" , text) )
28
+ }
You can’t perform that action at this time.
0 commit comments