     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
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64

    use std::str::FromStr;
    use std::collections::HashSet;
    use rpc::Dependencies;
    use ethcore_rpc::MetaIoHandler;

    #[derive(Debug, PartialEq, Eq, Hash, Copy, Clone)]
    pub enum Api {
    	/// Raw methods
    	Raw,
    	/// Miner-related methods
    	Miner,
    	/// BlockChain-related methods
    	BlockChain,
    	/// Network
    	Network,
    }

    #[derive(Debug, PartialEq, Eq)]
    pub enum ApiSet {
    	List(HashSet<Api>),
    }

    impl Default for ApiSet {
    	fn default() -> Self {
    		ApiSet::List(vec![Api::Raw, Api::Miner, Api::BlockChain, Api::Network].into_iter().collect())
    	}
    }

    impl FromStr for Api {
    	type Err = String;

    	fn from_str(s: &str) -> Result<Self, Self::Err> {
    		match s {
    			"raw" => Ok(Api::Raw),
    			"miner" => Ok(Api::Miner),
    			"blockchain" => Ok(Api::BlockChain),
    			"network" => Ok(Api::Network),
    			api => Err(format!("Unknown api: {}", api)),
    		}
    	}
    }

    impl ApiSet {
    	pub fn list_apis(&self) -> HashSet<Api> {
    		match *self {
    			ApiSet::List(ref apis) => apis.clone(),
    		}
    	}
    }

    pub fn setup_rpc(mut handler: MetaIoHandler<()>, apis: ApiSet, deps: Dependencies) -> MetaIoHandler<()> {
    	use ethcore_rpc::v1::*;

    	for api in apis.list_apis() {
    		match api {
    			Api::Raw => handler.extend_with(RawClient::new(RawClientCore::new(deps.local_sync_node.clone())).to_delegate()),
    			Api::Miner => handler.extend_with(MinerClient::new(MinerClientCore::new(deps.local_sync_node.clone())).to_delegate()),
    			Api::BlockChain => handler.extend_with(BlockChainClient::new(BlockChainClientCore::new(deps.network, deps.storage.clone())).to_delegate()),
    			Api::Network => handler.extend_with(NetworkClient::new(NetworkClientCore::new(deps.p2p_context.clone())).to_delegate()),
    		}
    	}

    	handler
    }

# 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`)