Struct wildland_cargo_lib::api::cargo_user::CargoUser
source · pub struct CargoUser { /* private fields */ }
Expand description
Structure representing a User.
It gives access to:
- user’s forest and containers,
- Foundation Storage API which includes the following methods:
Implementations§
source§impl CargoUser
impl CargoUser
pub fn new( this_device: String, all_devices: Vec<String>, forest: Forest, services: CargoUserServices ) -> Self
sourcepub fn automount(&self) -> Result<(), AutomountError>
pub fn automount(&self) -> Result<(), AutomountError>
Tries to mount containers that are set to be mounted automatically.
Containers can be set as automounted in local (device) or global (user’s) context. During automount records from both contexts are taken into account and ordered by time of creation.
This method can be called only if the application is in clean state - no containers have been mounted yet.
sourcepub fn find_containers(
&self,
filter: Option<CargoContainerFilter>,
mount_state: MountState
) -> Result<Vec<CargoContainer>, CatlibError>
pub fn find_containers( &self, filter: Option<CargoContainerFilter>, mount_state: MountState ) -> Result<Vec<CargoContainer>, CatlibError>
Returns vector of handles to containers found in the user’s forest.
Args:
filter
: filter that is passed to catlib, so the query to database could be optimizedmount_state
: specifies whether to include mounted, unmounted or all containers in results.
Example
let containers = user
.find_containers(
Some(CargoContainerFilter::or(
CargoContainerFilter::has_exact_path("/some/path".into()),
CargoContainerFilter::has_path_starting_with("/some/other/".into()),
)),
MountState::MountedOrUnmounted,
)
.unwrap();
sourcepub fn create_container(
&self,
name: String,
template: &StorageTemplate,
path: String,
encrypted: bool
) -> Result<CargoContainer, CoreXError>
pub fn create_container( &self, name: String, template: &StorageTemplate, path: String, encrypted: bool ) -> Result<CargoContainer, CoreXError>
Creates a new container within user’s forest and returns its handle
Example
let template = LocalFilesystemStorageTemplate {
local_dir: tmpdir.clone(),
container_dir: "{{ CONTAINER_NAME }}".to_owned(),
};
let container = user
.create_container(
"C1".to_owned(),
&template.into(),
"/some/path/".to_owned(),
false
)
.unwrap();
pub fn this_device(&self) -> &str
pub fn all_devices(&self) -> &[String]
sourcepub fn get_storage_templates(&self) -> Result<Vec<StorageTemplate>, CatlibError>
pub fn get_storage_templates(&self) -> Result<Vec<StorageTemplate>, CatlibError>
Returns vector of user’s storage templates
sourcepub fn save_storage_template(
&self,
tpl: &mut StorageTemplate
) -> Result<String, CatlibError>
pub fn save_storage_template( &self, tpl: &mut StorageTemplate ) -> Result<String, CatlibError>
Save StorageTemplate data in CatLib.
sourcepub fn request_free_tier_storage(
&self,
email: String
) -> Result<FreeTierProcessHandle, FsaError>
pub fn request_free_tier_storage( &self, email: String ) -> Result<FreeTierProcessHandle, FsaError>
Starts process of granting Free Tier Foundation Storage.
CargoUser
encapsulates FoundationStorageApi
functionalities in order to avoid requesting
Free Foundation Tier outside of the user context.
Returns FreeTierProcessHandle
structure which can be used to verify an email address and
finalize the process.
sourcepub fn verify_email(
&self,
process_handle: &FreeTierProcessHandle,
token: String
) -> Result<StorageTemplate, FsaError>
pub fn verify_email( &self, process_handle: &FreeTierProcessHandle, token: String ) -> Result<StorageTemplate, FsaError>
Finishes process of granting Free Tier Foundation Storage.
After successful server verification it saves Storage Template in LSS and saves information that storage has been granted in forest’s metadata in CatLib.
Returns the same storage template which is saved in LSS.
pub fn is_free_storage_granted(&self) -> Result<bool, CatlibError>
pub fn get_user_public_key(&self) -> Vec<u8> ⓘ
Creates a new shared container (or re-use one if it is already created) for the given path and target user’s public key. Returns a sharing message containing all the information needed to re-create the shared container on the target side.
Returns SharingMessage
.
Errors
- Returns
SharingError::Generic
Re-creates the shared container based on the SharingMessage
and mounts it in
the target path
Errors
- Returns
SharingError::Generic
sourcepub fn revoke_sharing(
&self,
wildland_object_id: String,
_pub_key: PubKey
) -> Result<(), SharingError>
pub fn revoke_sharing( &self, wildland_object_id: String, _pub_key: PubKey ) -> Result<(), SharingError>
Takes the Wildland object ID and the public key and tries to revoke access to the resource for the given user.
Errors
- Returns
SharingError::Generic
sourcepub fn get_pubkeys_having_access_to_object(
&self,
wildland_object_id: String
) -> Result<Vec<PubKey>, SharingError>
pub fn get_pubkeys_having_access_to_object( &self, wildland_object_id: String ) -> Result<Vec<PubKey>, SharingError>
Takes the Wildland object ID and returns collection of PubKeys for which the given resource has been shared with.
Returns vector of PubKey
related to users who has access to the given resource
Errors
- Returns
SharingError::Generic