Protocol

Struct Protocol 

Source
pub struct Protocol {
    pub name: String,
    pub options: Option<HashMap<String, Value>>,
    pub webdav: Option<WebDavProperties>,
    pub webapp: Option<WebAppProperties>,
    pub datatx: Option<DataTxProperties>,
    pub additional_protocols: HashMap<String, Value>,
}
Expand description

JSON object with specific options for each protocol.

The supported protocols are:

  • webdav, to access the data
  • webapp, to access remote web applications
  • datatx, to transfer the data to the remote endpoint

Other custom protocols might be added in the future.

§Single Protocol Legacy

use ocm_types::share::Protocol;
use std::collections::HashMap;
use serde_json::Value;
use serde_json::json;

#[allow(deprecated)]
let single_protocol_legacy = Protocol{
    name: "webdav".to_string(),
    options: Some(HashMap::from_iter(vec![
        ("sharedSecret".to_string(), Value::String("hfiuhworzwnur98d3wjiwhr".to_string())),
        ("permissions".to_string(), Value::String("some permissions scheme".to_string())),
    ].into_iter())),
    ..Default::default()
};
let json: Value = serde_json::from_str(r#"{
    "name": "webdav",
    "options": {
        "sharedSecret": "hfiuhworzwnur98d3wjiwhr",
        "permissions": "some permissions scheme"
    }
}"#).unwrap();
assert_eq!(json!(single_protocol_legacy), json);

§Single Protocol New

use ocm_types::share::Protocol;
use ocm_types::share::WebDavProperties;
use ocm_types::share::WebDavPermissions;
use std::collections::HashMap;
use serde_json::Value;
use serde_json::json;

let single_protocol_new = Protocol{
    name: "multi".to_string(),
    webdav: Some(WebDavProperties{
        uri: "7c084226-d9a1-11e6-bf26-cec0c932ce01".to_string(),
        shared_secret: Some("hfiuhworzwnur98d3wjiwhr".to_string()),
        permissions: vec![
            WebDavPermissions::Read,
            WebDavPermissions::Write,
        ],
        requirements: vec![]
    }),
    ..Default::default()
};
let json: Value = serde_json::from_str(r#"{
    "name": "multi",
    "webdav": {
        "uri": "7c084226-d9a1-11e6-bf26-cec0c932ce01",
        "sharedSecret": "hfiuhworzwnur98d3wjiwhr",
        "permissions": ["read", "write"]
    }
}"#).unwrap();
assert_eq!(json!(single_protocol_new), json);

§Multi Protocol

use ocm_types::share::Protocol;
use ocm_types::share::WebDavProperties;
use ocm_types::share::WebDavPermissions;
use ocm_types::share::WebDavRequirements;
use ocm_types::share::WebAppProperties;
use ocm_types::share::WebAppViewMode;
use ocm_types::share::DataTxProperties;
use std::collections::HashMap;
use serde_json::Value;
use serde_json::json;

let single_protocol_new = Protocol{
    name: "multi".to_string(),
    webdav: Some(WebDavProperties{
        uri: "7c084226-d9a1-11e6-bf26-cec0c932ce01".to_string(),
        shared_secret: Some("hfiuhworzwnur98d3wjiwhr".to_string()),
        permissions: vec![
            WebDavPermissions::Read,
            WebDavPermissions::Write
        ],
        requirements: vec![
            WebDavRequirements::MfaEnforced
        ]
    }),
    webapp: Some(WebAppProperties{
        uri: "7c084226-d9a1-11e6-bf26-cec0c932ce01".to_string(),
        shared_secret: Some("hfiuhworzwnur98d3wjiwhr".to_string()),
        view_mode: WebAppViewMode::Read
    }),
    datatx: Some(DataTxProperties{
        src_uri: "7c084226-d9a1-11e6-bf26-cec0c932ce01".to_string(),
        shared_secret: "hfiuhworzwnur98d3wjiwhr".to_string(),
        size: Some(100000)
    }),
    ..Default::default()
};
let json: Value = serde_json::from_str(r#"{
    "name": "multi",
    "webdav": {
        "uri": "7c084226-d9a1-11e6-bf26-cec0c932ce01",
        "sharedSecret": "hfiuhworzwnur98d3wjiwhr",
        "permissions": ["read", "write"],
        "requirements": ["mfa-enforced"]
    },
    "webapp": {
      "uri": "7c084226-d9a1-11e6-bf26-cec0c932ce01",
      "sharedSecret": "hfiuhworzwnur98d3wjiwhr",
      "viewMode": "read"
    },
    "datatx": {
     "srcUri": "7c084226-d9a1-11e6-bf26-cec0c932ce01",
     "sharedSecret": "hfiuhworzwnur98d3wjiwhr",
     "size": 100000
    }
}"#).unwrap();
assert_eq!(json!(single_protocol_new), json);

Fields§

§name: String

The name of the protocol. Default: multi. If multi is given, one or more protocol endpoints are expected to be defined according to the optional properties specified below. Otherwise, at least webdav is expected to be supported, and its options MAY be given in the opaque options payload for compatibility with v1.0 implementations (see examples). Note though that this format is deprecated. Warning: client implementers should be aware that v1.1 servers MAY support both webdav and multi, but v1.0 servers MAY only support webdav. This field may be removed in a future major version of the spec.

§options: Option<HashMap<String, Value>>
👎Deprecated

This property is now deprecated. Implementations are encouraged to transition to the new optional properties defined below, such that this field may be removed in a future major version of the spec.

§webdav: Option<WebDavProperties>§webapp: Option<WebAppProperties>§datatx: Option<DataTxProperties>§additional_protocols: HashMap<String, Value>

Any optional additional protocols supported for this resource MAY be provided here, along with their custom payload. Appropriate capabilities MUST be advertised in order for a sender to ensure the recipient can parse such customized payloads.

Trait Implementations§

Source§

impl Clone for Protocol

Source§

fn clone(&self) -> Protocol

Returns a duplicate 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 Protocol

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Protocol

Source§

fn default() -> Protocol

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Protocol

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Protocol

Source§

fn eq(&self, other: &Protocol) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Protocol

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for Protocol

Source§

impl StructuralPartialEq for Protocol

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,