pub struct CargoUser { /* private fields */ }
Expand description

Structure representing a User.

It gives access to:

Implementations§

source§

impl CargoUser

source

pub fn new( this_device: String, all_devices: Vec<String>, forest: Forest, services: CargoUserServices ) -> Self

source

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.

source

pub fn stringify(&self) -> String

Returns string representation of a CargoUser

source

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 optimized
  • mount_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();
source

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();
source

pub fn this_device(&self) -> &str

source

pub fn all_devices(&self) -> &[String]

source

pub fn get_storage_templates(&self) -> Result<Vec<StorageTemplate>, CatlibError>

Returns vector of user’s storage templates

source

pub fn save_storage_template( &self, tpl: &mut StorageTemplate ) -> Result<String, CatlibError>

Save StorageTemplate data in CatLib.

source

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.

source

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.

source

pub fn is_free_storage_granted(&self) -> Result<bool, CatlibError>

source

pub fn get_user_public_key(&self) -> Vec<u8>

source

pub fn share( &self, wildland_object_id: String, pub_key: PubKey ) -> Result<SharingMessage, SharingError>

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
source

pub fn add_shared_container( &self, _sharing_message: SharingMessage, _path: String ) -> Result<(), SharingError>

Re-creates the shared container based on the SharingMessage and mounts it in the target path

Errors
source

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
source

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

Trait Implementations§

source§

impl Clone for CargoUser

source§

fn clone(&self) -> CargoUser

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CargoUser

source§

fn fmt(&self, __f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Any for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more