Created
January 20, 2013 19:23
-
-
Save jld/4580989 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| impl SetupRequest: xio::IOable { | |
| static fn read<E: xio::Endian Copy>(_e: E, _buf: &_buf/[u8]) -> | |
| (SetupRequest, &_buf/[u8]) { | |
| { | |
| let (byte_order, _buf) = xio::IOable::read(_e, _buf); | |
| { | |
| let _buf = vec::view(_buf, 1, _buf.len()); | |
| { | |
| let (protocol_major_version, _buf) = | |
| xio::IOable::read(_e, _buf); | |
| { | |
| let (protocol_minor_version, _buf) = | |
| xio::IOable::read(_e, _buf); | |
| { | |
| let (authorization_protocol_name_len, _buf) = | |
| xio::IOable::read(_e, _buf); | |
| let authorization_protocol_name_len: u16 = | |
| authorization_protocol_name_len; | |
| { | |
| let (authorization_protocol_data_len, _buf) = | |
| xio::IOable::read(_e, _buf); | |
| let authorization_protocol_data_len: u16 = | |
| authorization_protocol_data_len; | |
| { | |
| let _buf = vec::view(_buf, 2, _buf.len()); | |
| { | |
| let (authorization_protocol_name, | |
| _buf) = | |
| xio::read_vec(_e, _buf, | |
| (authorization_protocol_name_len | |
| as uint)); | |
| { | |
| let _buf = | |
| vec::view(_buf, | |
| -(authorization_protocol_name_len | |
| as uint) & 3, | |
| _buf.len()); | |
| { | |
| let (authorization_protocol_data, | |
| _buf) = | |
| xio::read_vec(_e, _buf, | |
| (authorization_protocol_data_len | |
| as | |
| uint)); | |
| { | |
| let _buf = | |
| vec::view(_buf, | |
| -(authorization_protocol_data_len | |
| as | |
| uint) | |
| & 3, | |
| _buf.len()); | |
| { | |
| (SetupRequest{byte_order: | |
| byte_order, | |
| protocol_major_version: | |
| protocol_major_version, | |
| protocol_minor_version: | |
| protocol_minor_version, | |
| authorization_protocol_name: | |
| authorization_protocol_name, | |
| authorization_protocol_data: | |
| authorization_protocol_data,}, | |
| _buf) | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| fn size_of(&self) -> uint { | |
| self.byte_order.size_of() + | |
| (1) + | |
| self.protocol_major_version.size_of() + | |
| self.protocol_minor_version.size_of() + | |
| { | |
| let authorization_protocol_name_len = | |
| self.authorization_protocol_name.len() as u16; | |
| authorization_protocol_name_len.size_of() + | |
| { | |
| let authorization_protocol_data_len = | |
| self.authorization_protocol_data.len() | |
| as u16; | |
| authorization_protocol_data_len.size_of() | |
| + | |
| (2) + | |
| vec::foldl(0, | |
| self.authorization_protocol_name, | |
| |_a, _elem| | |
| _a + | |
| _elem.size_of()) | |
| + | |
| (-(authorization_protocol_name_len | |
| as uint) & 3) + | |
| vec::foldl(0, | |
| self.authorization_protocol_data, | |
| |_a, _elem| | |
| _a + | |
| _elem.size_of()) | |
| + | |
| (-(authorization_protocol_data_len | |
| as uint) & 3) + | |
| 0 | |
| } | |
| } | |
| } | |
| fn write<E: xio::Endian Copy>(&self, _e: E, _buf: &_buf/[mut u8]) -> | |
| &_buf/[mut u8] { | |
| { | |
| let _buf = self.byte_order.write(_e, _buf); | |
| { | |
| let _buf = vec::mut_view(_buf, 1, _buf.len()); | |
| { | |
| let _buf = self.protocol_major_version.write(_e, _buf); | |
| { | |
| let _buf = | |
| self.protocol_minor_version.write(_e, _buf); | |
| { | |
| let authorization_protocol_name_len = | |
| self.authorization_protocol_name.len() as u16; | |
| let _buf = | |
| authorization_protocol_name_len.write(_e, | |
| _buf); | |
| { | |
| let authorization_protocol_data_len = | |
| self.authorization_protocol_data.len() as | |
| u16; | |
| let _buf = | |
| authorization_protocol_data_len.write(_e, | |
| _buf); | |
| { | |
| let _buf = | |
| vec::mut_view(_buf, 2, _buf.len()); | |
| { | |
| assert (self.authorization_protocol_name.len() | |
| == | |
| (authorization_protocol_name_len | |
| as uint)); | |
| let _buf = | |
| xio::write_vec(_e, _buf, | |
| self.authorization_protocol_name); | |
| { | |
| let _buf = | |
| vec::mut_view(_buf, | |
| -(authorization_protocol_name_len | |
| as uint) & | |
| 3, | |
| _buf.len()); | |
| { | |
| assert (self.authorization_protocol_data.len() | |
| == | |
| (authorization_protocol_data_len | |
| as uint)); | |
| let _buf = | |
| xio::write_vec(_e, _buf, | |
| self.authorization_protocol_data); | |
| { | |
| let _buf = | |
| vec::mut_view(_buf, | |
| -(authorization_protocol_data_len | |
| as | |
| uint) | |
| & 3, | |
| _buf.len()); | |
| _buf | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment