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
16use std::sync::Arc;
17
18/* === Constants === */
19
20/* === Macros === */
21
22/* === Type Aliases === */
23
24pub type AccessError = Box<dyn std::error::Error + Send + Sync>;
25pub type DiscoveryPage = (Vec<u8>, Option<String>);
26
27/* === Structs === */
28
29#[derive(Clone)]
30pub struct DiscoveryAccess(pub Arc<dyn Discovery>);
31#[derive(Clone)]
32pub struct GrantAccess(pub Arc<dyn GrantAuthority>);
33
34/* === Enums === */
35
36/* === Traits === */
37
38pub trait Discovery: Send + Sync {
39    fn discover(&self, after: Option<&str>, rows: usize, bytes: usize) -> Result<DiscoveryPage, AccessError>;
40}
41pub trait GrantAuthority: Send + Sync {
42    fn admit(&self, grant: &harmos_domain::plugin::Grant) -> Result<(), AccessError>;
43}
44
45/* === Implementations === */
46
47/* === Public Functions === */
48
49/* === Private Functions === */
50
51/* === Tests === */