2022-10-31 15:19:56 +01:00
|
|
|
@0xf8f8864ba0678056;
|
|
|
|
|
|
|
|
using CSharp = import "programming_language/csharp.capnp";
|
|
|
|
$CSharp.namespace("FabAccessAPI.Schema");
|
|
|
|
|
|
|
|
using import "/capnp/rpc.capnp".SturdyRef;
|
|
|
|
|
2022-11-01 11:03:26 +01:00
|
|
|
using import "persistent.capnp".Persistent;
|
2023-11-23 12:36:28 +01:00
|
|
|
using import "resource.capnp".Resource;
|
|
|
|
using import "notify.capnp".Notifiable;
|
|
|
|
using import "utils.capnp".Fallible;
|
|
|
|
using import "utils.capnp".OID;
|
|
|
|
using import "utils.capnp".Map;
|
2022-10-31 15:19:56 +01:00
|
|
|
|
2022-11-01 12:11:53 +01:00
|
|
|
interface Claimable {
|
2023-11-23 12:36:28 +01:00
|
|
|
claim @0 () -> Fallible(Claim, ClaimError);
|
2022-10-31 15:19:56 +01:00
|
|
|
# returns NULL if the resource is *currently* not claimable.
|
|
|
|
# drop the returned claim capability to unclaim it.
|
2023-11-23 12:36:28 +01:00
|
|
|
|
|
|
|
interface ClaimError {
|
|
|
|
|
|
|
|
}
|
2022-10-31 15:19:56 +01:00
|
|
|
}
|
|
|
|
|
2022-11-01 12:11:53 +01:00
|
|
|
interface Lockable {
|
|
|
|
restore @0 ( sturdy :SturdyRef ) -> ( lock :Lock );
|
2023-11-23 12:36:28 +01:00
|
|
|
# Restore a previously saved SturdyRef pointing to a Lock
|
2022-11-01 12:11:53 +01:00
|
|
|
|
2022-11-01 12:44:33 +01:00
|
|
|
lock @1 () -> ( lock :Lock );
|
2024-03-01 15:39:30 +01:00
|
|
|
# Take exclusive access to a resource, disowning all other claims on this
|
|
|
|
# resource.
|
2022-11-01 12:11:53 +01:00
|
|
|
#
|
2024-03-01 15:39:30 +01:00
|
|
|
# On resources that do not allow concurrent claims to exist this method
|
|
|
|
# behaves similar to `claim`, however it will also succeed if a resource is
|
|
|
|
# already claimed, disowning the previous claim. On resources that do
|
|
|
|
# allow concurrent claims this method will disown all current claims on a
|
|
|
|
# resource and prevent new claims from being granted until the returned
|
|
|
|
# Lock capability is dropped. A call to `lock` on a resource that is
|
|
|
|
# already locked will succeed, invalidating the former lock.
|
2022-11-01 12:11:53 +01:00
|
|
|
}
|
|
|
|
|
2023-11-23 12:36:28 +01:00
|
|
|
interface Claim extends (Notifiable) {
|
|
|
|
resource @0 () -> ( resource :Resource );
|
|
|
|
# Pointer back to the resource this claim comes from. Primarily useful when restoring persisted
|
|
|
|
# claims or restoring after a connection failure.
|
2022-11-01 11:54:01 +01:00
|
|
|
|
2023-11-23 12:36:28 +01:00
|
|
|
traits @1 () -> Map(OID, AnyPointer);
|
|
|
|
|
|
|
|
disown @2 ();
|
|
|
|
# Disown this claim
|
2022-10-31 15:19:56 +01:00
|
|
|
}
|
2022-11-01 12:11:53 +01:00
|
|
|
|
|
|
|
interface Lock extends (Claim) {
|
|
|
|
# An exclusive claim on a resource. Only a single Lock may exist for any given resource.
|
|
|
|
|
|
|
|
downgrade @0 () -> ( claim :Claim );
|
|
|
|
# Downgrade a lock to a claim, allowing additional claims to be granted on resources that allow
|
2022-11-01 12:44:33 +01:00
|
|
|
# for concurrent access. Calling this capability will invalidate the Lock capability.
|
2022-11-01 12:11:53 +01:00
|
|
|
}
|