aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/src/main/java/com/wireguard/android/configStore/ConfigStore.kt
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-03-16 12:45:47 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2020-03-19 09:24:47 +0530
commit94c864503ea3a53f34cc48071b2522fc7250c012 (patch)
tree978df58de54e19eb46d0360ecf4ef8cd0281852e /ui/src/main/java/com/wireguard/android/configStore/ConfigStore.kt
parentstrings: Update Japanese Translation (diff)
downloadwireguard-android-94c864503ea3a53f34cc48071b2522fc7250c012.tar.xz
wireguard-android-94c864503ea3a53f34cc48071b2522fc7250c012.zip
ui: Convert configStore package to Kotlin
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
Diffstat (limited to 'ui/src/main/java/com/wireguard/android/configStore/ConfigStore.kt')
-rw-r--r--ui/src/main/java/com/wireguard/android/configStore/ConfigStore.kt68
1 files changed, 68 insertions, 0 deletions
diff --git a/ui/src/main/java/com/wireguard/android/configStore/ConfigStore.kt b/ui/src/main/java/com/wireguard/android/configStore/ConfigStore.kt
new file mode 100644
index 00000000..6c381b69
--- /dev/null
+++ b/ui/src/main/java/com/wireguard/android/configStore/ConfigStore.kt
@@ -0,0 +1,68 @@
+/*
+ * Copyright © 2017-2019 WireGuard LLC. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ */
+package com.wireguard.android.configStore
+
+import com.wireguard.config.Config
+
+/**
+ * Interface for persistent storage providers for WireGuard configurations.
+ */
+interface ConfigStore {
+ /**
+ * Create a persistent tunnel, which must have a unique name within the persistent storage
+ * medium.
+ *
+ * @param name The name of the tunnel to create.
+ * @param config Configuration for the new tunnel.
+ * @return The configuration that was actually saved to persistent storage.
+ */
+ @Throws(Exception::class)
+ fun create(name: String, config: Config): Config
+
+ /**
+ * Delete a persistent tunnel.
+ *
+ * @param name The name of the tunnel to delete.
+ */
+ @Throws(Exception::class)
+ fun delete(name: String)
+
+ /**
+ * Enumerate the names of tunnels present in persistent storage.
+ *
+ * @return The set of present tunnel names.
+ */
+ fun enumerate(): Set<String>
+
+ /**
+ * Load the configuration for the tunnel given by `name`.
+ *
+ * @param name The identifier for the configuration in persistent storage (i.e. the name of the
+ * tunnel).
+ * @return An in-memory representation of the configuration loaded from persistent storage.
+ */
+ @Throws(Exception::class)
+ fun load(name: String): Config
+
+ /**
+ * Rename the configuration for the tunnel given by `name`.
+ *
+ * @param name The identifier for the existing configuration in persistent storage.
+ * @param replacement The new identifier for the configuration in persistent storage.
+ */
+ @Throws(Exception::class)
+ fun rename(name: String, replacement: String)
+
+ /**
+ * Save the configuration for an existing tunnel given by `name`.
+ *
+ * @param name The identifier for the configuration in persistent storage (i.e. the name of
+ * the tunnel).
+ * @param config An updated configuration object for the tunnel.
+ * @return The configuration that was actually saved to persistent storage.
+ */
+ @Throws(Exception::class)
+ fun save(name: String, config: Config): Config
+}