pub struct ChannelListQuery {
    pub page: u64,
    pub validator: Option<ValidatorId>,
    pub chains: Vec<ChainId>,
}
Expand description

GET /v5/channel/list query

Examples

use primitives::{
    sentry::channel_list::ChannelListQuery,
    test_util::{IDS, LEADER},
    ChainId,
};

fn main() {
    // An empty query
    {
        let empty = "";
        let empty_expected = ChannelListQuery {
            page: 0,
            validator: None,
            chains: vec![],
        };

        assert_eq!(empty_expected, serde_qs::from_str(empty).unwrap());
    }

    // Query with `page`
    {
        let only_page = "page=14";
        let only_page_expected = ChannelListQuery {
            page: 14,
            validator: None,
            chains: vec![],
        };

        assert_eq!(only_page_expected, serde_qs::from_str(only_page).unwrap());
    }

    // Query with `validator`
    {
        let only_validator = "validator=0x80690751969B234697e9059e04ed72195c3507fa";
        let only_validator_expected = ChannelListQuery {
            page: 0,
            validator: Some(IDS[&LEADER]),
            chains: vec![],
        };

        assert_eq!(
            only_validator_expected,
            serde_qs::from_str(only_validator).unwrap()
        );
    }

    // Query with `chains`
    {
        let chains_query = "chains[]=1&chains[]=1337";
        let chains_expected = ChannelListQuery {
            page: 0,
            validator: None,
            chains: vec![ChainId::new(1), ChainId::new(1337)],
        };

        assert_eq!(chains_expected, serde_qs::from_str(chains_query).unwrap());
    }

    // Query with all parameters
    {
        let all_query =
            "page=14&validator=0x80690751969B234697e9059e04ed72195c3507fa&chains[]=1&chains[]=1337";
        let all_expected = ChannelListQuery {
            page: 14,
            validator: Some(IDS[&LEADER]),
            chains: vec![ChainId::new(1), ChainId::new(1337)],
        };

        assert_eq!(all_expected, serde_qs::from_str(all_query).unwrap());
    }
}

Fields

page: u64

default is u64::default() = 0

validator: Option<ValidatorId>

Returns only the Channels containing a specified validator if provided.

chains: Vec<ChainId>

Returns only the Channels from the specified ChainIds.

Trait Implementations

Formats the value using the given formatter. Read more
Deserialize this value from the given Serde deserializer. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more