Struct in3::in3::Client [−][src]
Client struct
Implementations
impl Client
[src]
pub fn new(chain_id: ChainId) -> Box<Client>
[src]
Constructs a new Box<Client>
for specified chain Id.
Defaults to HttpTransport
with no signer and storage.
Example
use in3::prelude::*; let client = Client::new(chain::MAINNET);
Trait Implementations
impl Client for Client
[src]
fn id(&self) -> u32
[src]
fn configure(&mut self, config: &str) -> In3Result<()>
[src]
Configures the IN3 client using a JSON str.
Example with supported options
let mut client = Client::new(chain::MAINNET); let err = client.configure(r#"{ "autoUpdateList": true, "signatureCount": 0, "finality": 0, "includeCode": false, "maxAttempts": 7, "keepIn3": false, "stats": true, "useBinary": false, "useHttp": false, "maxVerifiedHashes": 5, "timeout": 10000, "minDeposit": 0, "nodeProps": 0, "nodeLimit": 0, "proof": "standard", "requestCount": 1, "nodeRegistry": { "contract": "0x4c396dcf50ac396e5fdea18163251699b5fcca25", "registryId": "0x92eb6ad5ed9068a24c1c85276cd7eb11eda1e8c50b17fbaffaf3e8396df4becf", "needsUpdate": true, "avgBlockTime": 6 } }"#); assert!(err.is_ok());
fn set_transport(&mut self, transport: Box<dyn Transport>)
[src]
Sets custom transport.
Example
use in3::transport::MockTransport; client.set_transport(Box::new(MockTransport { responses: vec![( "eth_blockNumber", r#"[{"jsonrpc":"2.0","id":1,"result":"0x96bacd"}]"#, )], }));
fn set_signer(&mut self, signer: Box<dyn Signer>)
[src]
Sets custom signer.
Example
use in3::signer::In3Signer; use std::convert::TryInto; client.set_signer(Box::new(In3Signer::new( "8da4ef21b864d2cc526dbdb2a120bd2874c36c9d0a1fb7f8c63d7f7a8b41de8f" .try_into().unwrap())));
fn set_storage(&mut self, storage: Box<dyn Storage>)
[src]
Sets custom storage.
Example
use std::collections::HashMap; struct MemStorage { buf: HashMap<String, Vec<u8>> } impl Default for MemStorage { fn default() -> Self { MemStorage{buf: HashMap::new()} } } impl Storage for MemStorage { fn get(&self,key: &str) -> Option<Vec<u8>> { Some(self.buf.get(key)?.clone()) } fn set(&mut self,key: &str,value: &[u8]) { self.buf.insert(key.to_string(), value.into()); } fn clear(&mut self) { self.buf.clear() } } client.set_storage(Box::new(MemStorage::default()));
fn rpc<'life0, 'life1, 'async_trait>(
&'life0 mut self,
call: &'life1 str
) -> Pin<Box<dyn Future<Output = In3Result<String>> + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
[src]
&'life0 mut self,
call: &'life1 str
) -> Pin<Box<dyn Future<Output = In3Result<String>> + 'async_trait>> where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
impl Drop for Client
[src]
impl From<*mut in3_t_> for &mut Client
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl !Send for Client
impl !Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,