Skip to main content

harmos_sdk/operations/
access.rs

1/* ***
2 *
3 * Harmos
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 *
7 * ***
8 */
9
10/* === Modules === */
11
12/* === Re-Exports === */
13
14/* === Imports === */
15
16// Standard Library Imports
17use std::sync::Arc;
18// Third Party Imports
19
20// Local Imports
21
22/* === Constants === */
23
24/* === Macros === */
25
26/* === Type Aliases === */
27
28pub type AccessError = Box<dyn std::error::Error + Send + Sync>;
29pub type DiscoveryPage = (Vec<u8>, Option<String>);
30
31/* === Structs === */
32
33#[derive(Clone)]
34pub struct DiscoveryAccess(pub Arc<dyn Discovery>);
35#[derive(Clone)]
36pub struct GrantAccess(pub Arc<dyn GrantAuthority>);
37
38/* === Enums === */
39
40/* === Traits === */
41
42pub trait Discovery: Send + Sync {
43    fn discover(&self, after: Option<&str>, rows: usize, bytes: usize) -> Result<DiscoveryPage, AccessError>;
44}
45pub trait GrantAuthority: Send + Sync {
46    fn admit(&self, grant: &harmos_domain::plugin::Grant) -> Result<(), AccessError>;
47}
48
49/* === Implementations === */
50
51/* === Public Functions === */
52
53/* === Private Functions === */
54
55/* === Tests === */