@@ -357,6 +357,14 @@ impl<'a> TLVElement<'a> {
357
357
}
358
358
}
359
359
360
+ pub fn i16 ( & self ) -> Result < i16 , Error > {
361
+ match self . element_type {
362
+ ElementType :: S8 ( a) => Ok ( a. into ( ) ) ,
363
+ ElementType :: S16 ( a) => Ok ( a) ,
364
+ _ => Err ( ErrorCode :: TLVTypeMismatch . into ( ) ) ,
365
+ }
366
+ }
367
+
360
368
pub fn u16 ( & self ) -> Result < u16 , Error > {
361
369
match self . element_type {
362
370
ElementType :: U8 ( a) => Ok ( a. into ( ) ) ,
@@ -365,6 +373,15 @@ impl<'a> TLVElement<'a> {
365
373
}
366
374
}
367
375
376
+ pub fn i32 ( & self ) -> Result < i32 , Error > {
377
+ match self . element_type {
378
+ ElementType :: S8 ( a) => Ok ( a. into ( ) ) ,
379
+ ElementType :: S16 ( a) => Ok ( a. into ( ) ) ,
380
+ ElementType :: S32 ( a) => Ok ( a) ,
381
+ _ => Err ( ErrorCode :: TLVTypeMismatch . into ( ) ) ,
382
+ }
383
+ }
384
+
368
385
pub fn u32 ( & self ) -> Result < u32 , Error > {
369
386
match self . element_type {
370
387
ElementType :: U8 ( a) => Ok ( a. into ( ) ) ,
@@ -374,6 +391,16 @@ impl<'a> TLVElement<'a> {
374
391
}
375
392
}
376
393
394
+ pub fn i64 ( & self ) -> Result < i64 , Error > {
395
+ match self . element_type {
396
+ ElementType :: S8 ( a) => Ok ( a. into ( ) ) ,
397
+ ElementType :: S16 ( a) => Ok ( a. into ( ) ) ,
398
+ ElementType :: S32 ( a) => Ok ( a. into ( ) ) ,
399
+ ElementType :: S64 ( a) => Ok ( a) ,
400
+ _ => Err ( ErrorCode :: TLVTypeMismatch . into ( ) ) ,
401
+ }
402
+ }
403
+
377
404
pub fn u64 ( & self ) -> Result < u64 , Error > {
378
405
match self . element_type {
379
406
ElementType :: U8 ( a) => Ok ( a. into ( ) ) ,
0 commit comments