     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48

    use std::io;
    use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
    use ser::{Serializable, Stream, Deserializable, Reader, Error as ReaderError};

    #[derive(Debug, Default, PartialEq, Clone, Copy)]
    pub struct Port(u16);

    impl From<u16> for Port {
    	fn from(port: u16) -> Self {
    		Port(port)
    	}
    }

    impl From<Port> for u16 {
    	fn from(port: Port) -> Self {
    		port.0
    	}
    }

    impl Serializable for Port {
    	fn serialize(&self, stream: &mut Stream) {
    		stream.write_u16::<BigEndian>(self.0).unwrap();
    	}
    }

    impl Deserializable for Port {
    	fn deserialize<T>(reader: &mut Reader<T>) -> Result<Self, ReaderError> where T: io::Read {
    		Ok(try!(reader.read_u16::<BigEndian>().map(Port)))
    	}
    }

    #[cfg(test)]
    mod	tests {
    	use ser::{serialize, deserialize};
    	use super::Port;

    	#[test]
    	fn test_port_serialize() {
    		assert_eq!(serialize(&Port::from(1)), "0001".into());
    		assert_eq!(serialize(&Port::from(0x1234)), "1234".into());
    	}

    	#[test]
    	fn test_port_deserialize() {
    		assert_eq!(Port::from(1), deserialize(&[0x00u8, 0x01] as &[u8]).unwrap());
    		assert_eq!(Port::from(0x1234), deserialize(&[0x12u8, 0x34] as &[u8]).unwrap());
    	}
    }

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)