pub struct PastryNode { /* private fields */ }Expand description
An instance of a Pastry node.
Implementations§
Source§impl PastryNode
impl PastryNode
Sourcepub fn new(
config: Config,
addr: SocketAddr,
pub_addr: SocketAddr,
) -> Result<Self>
pub fn new( config: Config, addr: SocketAddr, pub_addr: SocketAddr, ) -> Result<Self>
Sourcepub async fn bootstrap_and_serve(
self,
bootstrap_addr: Option<&str>,
) -> Result<()>
pub async fn bootstrap_and_serve( self, bootstrap_addr: Option<&str>, ) -> Result<()>
Sourcepub fn get_public_address(&self) -> String
pub fn get_public_address(&self) -> String
Gets the public Pastry node address.
Source§impl PastryNode
impl PastryNode
Sourcepub async fn get_kv(&self, key: &[u8]) -> Result<Option<Vec<u8>>>
pub async fn get_kv(&self, key: &[u8]) -> Result<Option<Vec<u8>>>
Retrieves a value associated with the given key stored in the Pastry network.
§Arguments
key- A slice of bytes representing the key for which the value is requested.
§Returns
Returns a Result which is:
Ok(Some(Vec<u8>))if the key exists, containing the associated value.Ok(None)if the key does not exist.Err(e)whereeencapsulates any error encountered during the operation.
Sourcepub async fn set_kv(&self, key: &[u8], value: &[u8]) -> Result<Option<Vec<u8>>>
pub async fn set_kv(&self, key: &[u8], value: &[u8]) -> Result<Option<Vec<u8>>>
Sets a value for a given key in the Pastry network.
§Arguments
key- A slice of bytes representing the key to which the value is to be associated.value- A slice of bytes representing the value to be set.
§Returns
Returns a Result which is:
Ok(Some(Vec<u8>))if the key existed and the value was replaced, containing the old value.Ok(None)if the key did not exist and a new entry was created.Err(e)whereeencapsulates any error encountered during the operation.
Sourcepub async fn delete_kv(&self, key: &[u8]) -> Result<Option<Vec<u8>>>
pub async fn delete_kv(&self, key: &[u8]) -> Result<Option<Vec<u8>>>
Deletes the value associated with the given key in the Pastry network.
§Arguments
key- A slice of bytes representing the key whose associated value is to be deleted.
§Returns
Returns a Result which is:
Ok(Some(Vec<u8>))if the key existed and the value was successfully deleted, containing the deleted value.Ok(None)if the key did not exist.Err(e)whereeencapsulates any error encountered during the operation.
Trait Implementations§
Source§impl Clone for PastryNode
impl Clone for PastryNode
Source§fn clone(&self) -> PastryNode
fn clone(&self) -> PastryNode
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PastryNode
impl !RefUnwindSafe for PastryNode
impl Send for PastryNode
impl Sync for PastryNode
impl Unpin for PastryNode
impl !UnwindSafe for PastryNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request