client/rpc/
metadata.rs

1// Copyright 2015-2019 Parity Technologies (UK) Ltd.
2// This file is part of Parity Ethereum.
3
4// Parity Ethereum is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Parity Ethereum is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Parity Ethereum.  If not, see <http://www.gnu.org/licenses/>.
16
17//! Parity RPC requests Metadata.
18use super::types::Origin;
19use jsonrpc_core;
20use jsonrpc_pubsub::{PubSubMetadata, Session};
21use std::sync::Arc;
22
23/// RPC methods metadata.
24#[derive(Clone, Default, Debug)]
25pub struct Metadata {
26    /// Request origin
27    pub origin: Origin,
28    /// Request PubSub Session
29    pub session: Option<Arc<Session>>,
30}
31
32impl jsonrpc_core::Metadata for Metadata {}
33
34impl PubSubMetadata for Metadata {
35    fn session(&self) -> Option<Arc<Session>> { self.session.clone() }
36}