@@ -27,6 +27,7 @@ pub enum WireError {
2727 InvalidValueType ( u8 ) ,
2828 InvalidCaptureBindingMode ( u8 ) ,
2929 InvalidUtf8 ,
30+ InvalidResourceKey ( String ) ,
3031 StringTooLong ( usize ) ,
3132 CodeTooLong ( usize ) ,
3233 UnsupportedConstantType ( & ' static str ) ,
@@ -52,6 +53,9 @@ impl std::fmt::Display for WireError {
5253 write ! ( f, "invalid capture binding mode: {value}" )
5354 }
5455 WireError :: InvalidUtf8 => write ! ( f, "invalid utf-8 string" ) ,
56+ WireError :: InvalidResourceKey ( reason) => {
57+ write ! ( f, "invalid resource key: {reason}" )
58+ }
5559 WireError :: StringTooLong ( len) => write ! ( f, "string too long: {len}" ) ,
5660 WireError :: CodeTooLong ( len) => write ! ( f, "code too long: {len}" ) ,
5761 WireError :: UnsupportedConstantType ( kind) => {
@@ -1433,6 +1437,10 @@ fn write_schema(schema: &TypeSchema, out: &mut Vec<u8>) -> Result<(), WireError>
14331437 }
14341438 write_schema ( result, out) ?;
14351439 }
1440+ TypeSchema :: Resource ( key) => {
1441+ out. push ( 17 ) ;
1442+ write_string ( "schema resource key" , key. as_str ( ) , out) ?;
1443+ }
14361444 }
14371445 Ok ( ( ) )
14381446}
@@ -1496,6 +1504,12 @@ fn read_schema(cursor: &mut Cursor<'_>) -> Result<TypeSchema, WireError> {
14961504 let result = Box :: new ( read_schema ( cursor) ?) ;
14971505 Ok ( TypeSchema :: Callable { params, result } )
14981506 }
1507+ 17 => {
1508+ let key_text = cursor. read_string ( ) ?;
1509+ let key = crate :: host_api:: ResourceTypeKey :: new ( key_text)
1510+ . map_err ( |err| WireError :: InvalidResourceKey ( err. to_string ( ) ) ) ?;
1511+ Ok ( TypeSchema :: Resource ( key) )
1512+ }
14991513 other => Err ( WireError :: InvalidValueType ( other) ) ,
15001514 }
15011515}
0 commit comments