avm_interface/
particle_parameters.rs

1/*
2 * Copyright 2022 Fluence Labs Limited
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17use serde::Deserialize;
18use serde::Serialize;
19use std::borrow::Cow;
20
21/// Represents parameters obtained from a particle.
22#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct ParticleParameters<'ctx> {
24    pub init_peer_id: Cow<'ctx, str>,
25    pub particle_id: Cow<'ctx, str>,
26    pub timestamp: u64,
27    pub ttl: u32,
28    pub current_peer_id: Cow<'ctx, str>,
29}
30
31impl<'ctx> ParticleParameters<'ctx> {
32    pub fn new(
33        init_peer_id: Cow<'ctx, str>,
34        particle_id: Cow<'ctx, str>,
35        timestamp: u64,
36        ttl: u32,
37        current_peer_id: Cow<'ctx, str>,
38    ) -> Self {
39        Self {
40            init_peer_id,
41            particle_id,
42            timestamp,
43            ttl,
44            current_peer_id,
45        }
46    }
47}