1mod alert;
3mod block_template;
4mod blockchain;
5mod bytes;
6mod cell;
7mod debug;
8mod experiment;
9mod fee_estimator;
10mod fee_rate;
11mod fixed_bytes;
12mod indexer;
13mod info;
14mod json_schema;
15mod net;
16mod pool;
17mod primitive;
18mod proposal_short_id;
19mod subscription;
20mod uints;
21
22#[cfg(test)]
23mod tests;
24
25pub use self::alert::{Alert, AlertId, AlertMessage, AlertPriority};
26pub use self::block_template::{
27 BlockTemplate, CellbaseTemplate, TransactionTemplate, UncleTemplate,
28};
29pub use self::blockchain::{
30 Block, BlockEconomicState, BlockFilter, BlockIssuance, BlockResponse, BlockView,
31 BlockWithCyclesResponse, CellDep, CellInput, CellOutput, Consensus, DepType, Deployment,
32 EpochView, FeeRateStatistics, HardForkFeature, HardForks, Header, HeaderView, MerkleProof,
33 MinerReward, OutPoint, ProposalWindow, Ratio, Script, ScriptHashType, SoftFork, Status,
34 Transaction, TransactionAndWitnessProof, TransactionProof, TransactionView,
35 TransactionWithStatusResponse, TxStatus, UncleBlock, UncleBlockView,
36};
37pub use self::bytes::JsonBytes;
38pub use self::cell::{CellData, CellInfo, CellWithStatus};
39pub use self::debug::{ExtraLoggerConfig, MainLoggerConfig};
40pub use self::experiment::{DaoWithdrawingCalculationKind, EstimateCycles};
41pub use self::fee_estimator::EstimateMode;
42pub use self::fee_rate::FeeRateDef;
43pub use self::fixed_bytes::Byte32;
44pub use self::info::{ChainInfo, DeploymentInfo, DeploymentPos, DeploymentState, DeploymentsInfo};
45pub use self::net::{
46 BannedAddr, LocalNode, LocalNodeProtocol, NodeAddress, PeerSyncState, RemoteNode,
47 RemoteNodeProtocol, SyncState,
48};
49pub use self::pool::{
50 AncestorsScoreSortKey, EntryCompleted, OutputsValidator, PoolTransactionEntry,
51 PoolTransactionReject, PoolTxDetailInfo, RawTxPool, TxPoolEntries, TxPoolEntry, TxPoolIds,
52 TxPoolInfo,
53};
54pub use self::proposal_short_id::ProposalShortId;
55pub use self::subscription::Topic;
56pub use self::uints::{Uint32, Uint64, Uint128};
57pub use ckb_types::core::RationalU256;
58pub use indexer::{
59 IndexerCell, IndexerCellType, IndexerCellsCapacity, IndexerOrder, IndexerPagination,
60 IndexerRange, IndexerScriptType, IndexerSearchKey, IndexerSearchKeyFilter, IndexerSearchMode,
61 IndexerTip, IndexerTx, IndexerTxWithCell, IndexerTxWithCells,
62};
63pub use primitive::{
64 AsEpochNumberWithFraction, BlockNumber, Capacity, Cycle, EpochNumber, EpochNumberWithFraction,
65 Timestamp, Version,
66};
67use schemars::JsonSchema;
68pub use serde::{Deserialize, Serialize};
69
70use ckb_types::bytes::Bytes;
71
72#[derive(PartialEq, Eq, Hash, Debug, Serialize, Deserialize, Clone, JsonSchema)]
75#[serde(untagged)]
76pub enum Either<L, R> {
77 Left(L),
79 Right(R),
81}
82
83#[derive(PartialEq, Eq, Hash, Debug, Serialize, Deserialize, Clone, JsonSchema)]
90#[serde(transparent)]
91pub struct ResponseFormat<V> {
92 pub inner: Either<V, JsonBytes>,
94}
95
96pub enum ResponseFormatInnerType {
99 Json,
101 Hex,
103}
104
105impl<V> ResponseFormat<V> {
106 pub fn json(json: V) -> Self {
108 ResponseFormat {
109 inner: Either::Left(json),
110 }
111 }
112
113 pub fn hex(raw: Bytes) -> Self {
115 ResponseFormat {
116 inner: Either::Right(JsonBytes::from_bytes(raw)),
117 }
118 }
119}