Encodes and attempts to write the most efficient ext metadata implementation to the given write, returning the marker used. # Errors This function will return `ValueWriteError` on any I/O error occurred while writing either the marker or the data, except the EINTR, which is handled internally. # Panics Panics if `typeid` is negative, because it is reserved for future MessagePack extension incl
(wr: &mut W, len: u32, typeid: i8)
| 751 | /// Panics if `typeid` is negative, because it is reserved for future MessagePack extension |
| 752 | /// including 2-byte type information. |
| 753 | pub fn write_ext_meta<W>(wr: &mut W, len: u32, typeid: i8) -> Result<Marker, ValueWriteError> |
| 754 | where W: Write |
| 755 | { |
| 756 | assert!(typeid >= 0); |
| 757 | |
| 758 | let marker = match len { |
| 759 | 1 => { |
| 760 | try!(write_marker(wr, Marker::FixExt1)); |
| 761 | Marker::FixExt1 |
| 762 | } |
| 763 | 2 => { |
| 764 | try!(write_marker(wr, Marker::FixExt2)); |
| 765 | Marker::FixExt2 |
| 766 | } |
| 767 | 4 => { |
| 768 | try!(write_marker(wr, Marker::FixExt4)); |
| 769 | Marker::FixExt4 |
| 770 | } |
| 771 | 8 => { |
| 772 | try!(write_marker(wr, Marker::FixExt8)); |
| 773 | Marker::FixExt8 |
| 774 | } |
| 775 | 16 => { |
| 776 | try!(write_marker(wr, Marker::FixExt16)); |
| 777 | Marker::FixExt16 |
| 778 | } |
| 779 | len if len < 256 => { |
| 780 | try!(write_marker(wr, Marker::Ext8)); |
| 781 | try!(write_data_u8(wr, len as u8)); |
| 782 | Marker::Ext8 |
| 783 | } |
| 784 | len if len < 65536 => { |
| 785 | try!(write_marker(wr, Marker::Ext16)); |
| 786 | try!(write_data_u16(wr, len as u16)); |
| 787 | Marker::Ext16 |
| 788 | } |
| 789 | len => { |
| 790 | try!(write_marker(wr, Marker::Ext32)); |
| 791 | try!(write_data_u32(wr, len)); |
| 792 | Marker::Ext32 |
| 793 | } |
| 794 | }; |
| 795 | |
| 796 | try!(write_data_i8(wr, typeid)); |
| 797 | |
| 798 | Ok(marker) |
| 799 | } |
| 800 | |
| 801 | pub mod value { |
| 802 |
no test coverage detected