Interface

Struct Interface 

Source
pub struct Interface<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> Interface<'a>

Source

pub fn build(parser: &Parser, indexer: &Indexer, computer: &Computer) -> Self

Examples found in repository?
examples/main.rs (line 37)
10pub fn main() -> Result<()> {
11    let bitcoin_dir = Path::new(&std::env::var("HOME").unwrap())
12        .join("Library")
13        .join("Application Support")
14        .join("Bitcoin");
15    // let bitcoin_dir = Path::new("/Volumes/WD_BLACK1/bitcoin");
16
17    let blocks_dir = bitcoin_dir.join("blocks");
18
19    let outputs_dir = Path::new(&std::env::var("HOME").unwrap()).join(".brk");
20    fs::create_dir_all(&outputs_dir)?;
21    // let outputs_dir = Path::new("/Volumes/WD_BLACK1/brk");
22
23    let rpc = Box::leak(Box::new(bitcoincore_rpc::Client::new(
24        "http://localhost:8332",
25        bitcoincore_rpc::Auth::CookieFile(bitcoin_dir.join(".cookie")),
26    )?));
27
28    let exit = Exit::new();
29    exit.set_ctrlc_handler();
30
31    let parser = Parser::new(blocks_dir, rpc);
32
33    let indexer = Indexer::forced_import(&outputs_dir)?;
34
35    let computer = Computer::forced_import(&outputs_dir, &indexer, None)?;
36
37    let interface = Interface::build(&parser, &indexer, &computer);
38
39    dbg!(interface.search_and_format(Params {
40        index: Index::Height,
41        metrics: vec!["date"].into(),
42        rest: ParamsOpt::default().set_from(-1),
43    })?);
44    dbg!(interface.search_and_format(Params {
45        index: Index::Height,
46        metrics: vec!["date", "timestamp"].into(),
47        rest: ParamsOpt::default().set_from(-10).set_count(5),
48    })?);
49
50    Ok(())
51}
Source

pub fn get_height(&self) -> Height

Source

pub fn search( &self, params: &Params, ) -> Result<Vec<(String, &&dyn AnyCollectableVec)>>

Source

pub fn format( &self, metrics: Vec<(String, &&dyn AnyCollectableVec)>, params: &ParamsOpt, ) -> Result<Output>

Source

pub fn search_and_format(&self, params: Params) -> Result<Output>

Examples found in repository?
examples/main.rs (lines 39-43)
10pub fn main() -> Result<()> {
11    let bitcoin_dir = Path::new(&std::env::var("HOME").unwrap())
12        .join("Library")
13        .join("Application Support")
14        .join("Bitcoin");
15    // let bitcoin_dir = Path::new("/Volumes/WD_BLACK1/bitcoin");
16
17    let blocks_dir = bitcoin_dir.join("blocks");
18
19    let outputs_dir = Path::new(&std::env::var("HOME").unwrap()).join(".brk");
20    fs::create_dir_all(&outputs_dir)?;
21    // let outputs_dir = Path::new("/Volumes/WD_BLACK1/brk");
22
23    let rpc = Box::leak(Box::new(bitcoincore_rpc::Client::new(
24        "http://localhost:8332",
25        bitcoincore_rpc::Auth::CookieFile(bitcoin_dir.join(".cookie")),
26    )?));
27
28    let exit = Exit::new();
29    exit.set_ctrlc_handler();
30
31    let parser = Parser::new(blocks_dir, rpc);
32
33    let indexer = Indexer::forced_import(&outputs_dir)?;
34
35    let computer = Computer::forced_import(&outputs_dir, &indexer, None)?;
36
37    let interface = Interface::build(&parser, &indexer, &computer);
38
39    dbg!(interface.search_and_format(Params {
40        index: Index::Height,
41        metrics: vec!["date"].into(),
42        rest: ParamsOpt::default().set_from(-1),
43    })?);
44    dbg!(interface.search_and_format(Params {
45        index: Index::Height,
46        metrics: vec!["date", "timestamp"].into(),
47        rest: ParamsOpt::default().set_from(-10).set_count(5),
48    })?);
49
50    Ok(())
51}
Source

pub fn metric_to_index_to_vec(&self) -> &BTreeMap<&str, IndexToVec<'_>>

Source

pub fn index_to_metric_to_vec(&self) -> &BTreeMap<Index, MetricToVec<'_>>

Source

pub fn distinct_metric_count(&self) -> usize

Source

pub fn total_metric_count(&self) -> usize

Source

pub fn get_indexes(&self) -> &BTreeMap<&'static str, &'static [&'static str]>

Source

pub fn get_metrics(&self, pagination: PaginationParam) -> &[&str]

Source

pub fn get_index_to_vecids( &self, paginated_index: PaginatedIndexParam, ) -> Vec<&str>

Source

pub fn metric_to_indexes(&self, metric: String) -> Option<&Vec<&'static str>>

Source

pub fn parser(&self) -> &Parser

Source

pub fn indexer(&self) -> &Indexer

Source

pub fn computer(&self) -> &Computer

Auto Trait Implementations§

§

impl<'a> Freeze for Interface<'a>

§

impl<'a> !RefUnwindSafe for Interface<'a>

§

impl<'a> Send for Interface<'a>

§

impl<'a> Sync for Interface<'a>

§

impl<'a> Unpin for Interface<'a>

§

impl<'a> !UnwindSafe for Interface<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V