Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit fffd68b

Browse files
author
bitfl0wer
committed
gweruiowerioguioh;werghjklbsdfhjklgsdfuiohj;eryuioh;ersdfuiojsdfg
1 parent f473467 commit fffd68b

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/api/core/migration.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use super::*;
55
mod registration_required {
66
use http::StatusCode;
77
use reqwest::multipart::Form;
8+
use serde::Serialize;
89
use serde_json::json;
910

1011
use crate::api::{P2RequestBuilder, SendsRequest, matches_status_code};
@@ -18,10 +19,10 @@ mod registration_required {
1819
/// Only messages classified as
1920
/// ["Information not tied to a specific context"](https://docs.polyphony.chat/Protocol%20Specifications/core/#:~:text=Example%3A%20Information%20not,without%0Aany%20issues.)
2021
/// can be imported.
21-
pub async fn import_data_to_server(
22+
pub async fn import_data_to_server<M: Serialize>(
2223
&self,
2324
sensitive_solution: &str,
24-
data: P2Export,
25+
data: P2Export<M>,
2526
) -> HttpResult<()> {
2627
let endpoint = self.instance_url.join("/.p2/core/v1/migration/data/")?;
2728
let request = self

src/types/p2_export.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,35 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

5-
pub struct P2Export {} // TODO
5+
use std::collections::HashMap;
6+
7+
use super::ResourceAccessProperties;
8+
9+
/// A P2Export data export.
10+
pub struct P2Export<M> {
11+
/// Generic messages
12+
messages: MessageBatches<M>,
13+
}
14+
15+
pub struct MessageBatches<M> {
16+
rawr: Option<RawrContent<M>>,
17+
}
18+
19+
pub struct RawrContent<M> {
20+
resources: Vec<M>,
21+
access_properties: HashMap<String, ResourceAccessProperties>,
22+
}
623

724
#[cfg(feature = "reqwest")]
825
mod reqwest {
926
use crate::errors::InvalidInput;
1027

1128
use super::P2Export;
1229

13-
impl TryFrom<P2Export> for reqwest::multipart::Form {
30+
impl<M> TryFrom<P2Export<M>> for reqwest::multipart::Form {
1431
type Error = InvalidInput;
1532
// TODO
16-
fn try_from(value: P2Export) -> Result<Self, Self::Error> {
33+
fn try_from(value: P2Export<M>) -> Result<Self, Self::Error> {
1734
todo!()
1835
}
1936
}

0 commit comments

Comments
 (0)