[][src]Struct pbd::dua::DUA

pub struct DUA {
    pub agreement_name: String,
    pub location: String,
    pub agreed_dtm: u64,
}

Represents a Data Usage Agreement (DUA)

Fields

agreement_name: String

The common name of the Data Usage Agreement, (e.g.: For Billing Purpose)

location: String

The URI where the version of the DUA can be found, (e.g.: https://iStore.example.org/dua/v2/billing.pdf)

agreed_dtm: u64

The Unix Epoch time when the DUA was agreed to

Methods

impl DUA[src]

pub fn new(agreement: String, uri: String, agreed_on: u64) -> DUA[src]

Constructs a DUA object

Arguments

  • agreement: String - The common name of the Data Usage Agreement, (e.g.: For Billing Purpose).
  • uri: String - The URI where the version of the DUA can be found, (e.g.: https://iStore.example.org/dua/v2/billing.pdf).
  • agreed_on: String - The Unix Epoch time when the DUA was agreed to.

#Example

extern crate pbd;

use pbd::dua::DUA;

fn main() {
    let dua = DUA::new("For Billing Purpose".to_string(), "www.dua.org/billing.pdf".to_string(), 1553988607);
     
    match dua.agreement_name.as_ref() {
        "For Billing Purpose" => println!("We can use the data for sending a bill."),
        _ => println!("Oops: We can't use the data this way!")
    }
}

pub fn from_serialized(serialized: &str) -> DUA[src]

Constructs a DUA object from a serialized string

Arguments

  • serialized: &str - The string that represents the serialized object.

#Example

extern crate pbd;

use pbd::dua::DUA;

fn main() {
    let serialized = r#"{ "agreement_name": "billing", "location": "www.dua.org/billing.pdf", "agreed_dtm": 1553988607 }"#;
    let usage_agreement = DUA::from_serialized(&serialized);
     
    println!("{:?}", usage_agreement);
}

pub fn serialize(&mut self) -> String[src]

Serialize a DUA object

Arguments

  • serialized: &str - The string that represents the serialized object.

#Example

extern crate pbd;

use pbd::dua::DUA;

fn main() {
    let serialized = r#"{ "agreement_name": "billing", "location": "www.dua.org/billing.pdf", "agreed_dtm": 1553988607 }"#;
    let mut dua = DUA {
        agreement_name: "billing".to_string(),
        location: "www.dua.org/billing.pdf".to_string(),
        agreed_dtm: 1553988607,
    };

    let usage_agreement = dua.serialize();
     
    println!("{:?}", usage_agreement);
}

Trait Implementations

impl Clone for DUA[src]

impl Debug for DUA[src]

impl<'de> Deserialize<'de> for DUA[src]

impl Serialize for DUA[src]

Auto Trait Implementations

impl RefUnwindSafe for DUA

impl Send for DUA

impl Sync for DUA

impl Unpin for DUA

impl UnwindSafe for DUA

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

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

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

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

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