Service

Struct Service 

Source
pub struct Service { /* private fields */ }
Expand description

Generic Service Type. This provides the basis for all services in DSR.

Services should be constructed using the ServiceBuilder type

Implementations§

Source§

impl Service

Source

pub fn id(&self) -> Id

Source

pub fn update<U>(&mut self, update_fn: U) -> Result<(), Error>
where U: Fn(&mut Body, &mut Vec<Options>, &mut PrivateOptions),

Update a service. This allows in-place editing of descriptors and options and causes an update of the service version number as well as a reset of the data_index.

Source

pub fn is_origin(&self) -> bool

Source

pub fn public_key(&self) -> PublicKey

Source

pub fn private_key(&self) -> Option<PrivateKey>

Source

pub fn secret_key(&self) -> Option<SecretKey>

Source

pub fn set_private_key(&mut self, key: Option<PrivateKey>)

Source

pub fn set_secret_key(&mut self, key: Option<SecretKey>)

Trait Implementations§

Source§

impl Clone for Service

Source§

fn clone(&self) -> Service

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 Service

Source§

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

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

impl Default for Service

Source§

fn default() -> Service

Create a default / blank Service for further initialisation.

Source§

impl<'de> Deserialize<'de> for Service

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 Net for Service

Source§

fn build_request( &self, request_id: u16, kind: RequestKind, flags: Flags, ) -> Base

Generate a protocol request object from a request message

Source§

fn build_response( &self, request_id: u16, kind: ResponseKind, flags: Flags, ) -> Base

Generate a protocol response object from a response message (and it’s associated request)

Source§

fn encode_message<T: AsRef<[u8]> + AsMut<[u8]>>( &self, msg: Message, buff: T, ) -> Result<usize, Error>

Encode a message

Source§

impl PartialEq for Service

Source§

fn eq(&self, other: &Service) -> 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 Publisher for Service

Source§

fn publish_primary<T: AsRef<[u8]> + AsMut<[u8]>>( &mut self, buff: T, ) -> Result<(usize, Page), Error>

Publish generates a page to publishing for the given service.

Source§

fn publish_secondary<T: AsRef<[u8]> + AsMut<[u8]>>( &mut self, id: &Id, options: SecondaryOptions, buff: T, ) -> Result<(usize, Page), Error>

Secondary generates a secondary page using this service to be attached to / stored at the provided service ID

Source§

fn publish_data<T: AsRef<[u8]> + AsMut<[u8]>>( &mut self, options: DataOptions, buff: T, ) -> Result<(usize, Page), Error>

Create a data object for publishing with the provided options and encodes it into the provided buffer
Source§

impl Serialize for Service

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 Subscriber for Service

Source§

fn load(page: &Page) -> Result<Service, Error>

Create a service instance from a given page

Source§

fn apply_primary(&mut self, update: &Page) -> Result<bool, Error>

Apply an upgrade to an existing service. This consumes a new page and updates the service instance

Source§

fn validate_page(&mut self, page: &Page) -> Result<(), Error>

Validate a given secondary page published by this service
Source§

impl StructuralPartialEq for Service

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>,