layer_client/restart.rs
1// Copyright (c) Ankit Chaubey <ankitchaubey.dev@gmail.com>
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4// NOTE:
5// The "Layer" project is no longer maintained or supported.
6// Its original purpose for personal SDK/APK experimentation and learning
7// has been fulfilled.
8//
9// Please use Ferogram instead:
10// https://github.com/ankit-chaubey/ferogram
11// Ferogram will receive future updates and development, although progress
12// may be slower.
13//
14// Ferogram is an async Telegram MTProto client library written in Rust.
15// Its implementation follows the behaviour of the official Telegram clients,
16// particularly Telegram Desktop and TDLib, and aims to provide a clean and
17// modern async interface for building Telegram clients and tools.
18
19use std::time::Duration;
20
21pub trait ConnectionRestartPolicy: Send + Sync + 'static {
22 fn restart_interval(&self) -> Option<Duration>;
23}
24
25pub struct NeverRestart;
26
27impl ConnectionRestartPolicy for NeverRestart {
28 fn restart_interval(&self) -> Option<Duration> {
29 None
30 }
31}
32
33pub struct FixedInterval {
34 pub interval: Duration,
35}
36
37impl ConnectionRestartPolicy for FixedInterval {
38 fn restart_interval(&self) -> Option<Duration> {
39 Some(self.interval)
40 }
41}