ipfs_api_prelude/response/
key.rs

1// Copyright 2017 rust-ipfs-api Developers
2//
3// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
4// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5// http://opensource.org/licenses/MIT>, at your option. This file may not be
6// copied, modified, or distributed except according to those terms.
7//
8
9use crate::response::serde;
10use crate::serde::Deserialize;
11
12#[derive(Debug, Deserialize)]
13#[serde(rename_all = "PascalCase")]
14pub struct KeyPair {
15    pub name: String,
16    pub id: String,
17}
18
19#[derive(Debug, Deserialize)]
20#[serde(rename_all = "PascalCase")]
21pub struct KeyPairList {
22    #[serde(deserialize_with = "serde::deserialize_vec")]
23    pub keys: Vec<KeyPair>,
24}
25
26pub type KeyGenResponse = KeyPair;
27
28pub type KeyListResponse = KeyPairList;
29
30#[derive(Debug, Deserialize)]
31#[serde(rename_all = "PascalCase")]
32pub struct KeyRenameResponse {
33    pub was: String,
34    pub now: String,
35    pub id: String,
36    pub overwrite: bool,
37}
38
39pub type KeyRmResponse = KeyPairList;
40
41#[cfg(test)]
42mod tests {
43    deserialize_test!(v0_key_gen_0, KeyGenResponse);
44    deserialize_test!(v0_key_list_0, KeyListResponse);
45    deserialize_test!(v0_key_rename_0, KeyRenameResponse);
46}