pub struct Peer<L: BucketLogProvider> { /* private fields */ }Expand description
Overview of a peer’s state, generic over a bucket log provider. Provides everything that a peer needs in order to load data, interact with peers, and manage buckets.
Implementations§
Source§impl<L: BucketLogProvider> Peer<L>
impl<L: BucketLogProvider> Peer<L>
pub fn logs(&self) -> &L
pub fn blobs(&self) -> &BlobsStore
pub fn endpoint(&self) -> &Endpoint
pub fn log_provider(&self) -> &L
pub fn secret(&self) -> &SecretKey
pub fn socket(&self) -> &SocketAddr
pub fn id(&self) -> NodeId
Sourcepub async fn dispatch(&self, job: SyncJob) -> Result<()>
pub async fn dispatch(&self, job: SyncJob) -> Result<()>
Dispatch a sync job to the sync provider
The provider decides when/where this executes (immediately, queued, etc.)
Sourcepub async fn ping(&self, bucket_id: Uuid) -> Result<()>
pub async fn ping(&self, bucket_id: Uuid) -> Result<()>
Ping all peers in a bucket’s shares
Dispatches ping jobs to all peers listed in the bucket’s current manifest shares (except ourselves).
Sourcepub async fn ping_and_collect(
&self,
bucket_id: Uuid,
timeout: Option<Duration>,
) -> Result<HashMap<String, PingReplyStatus>>
pub async fn ping_and_collect( &self, bucket_id: Uuid, timeout: Option<Duration>, ) -> Result<HashMap<String, PingReplyStatus>>
Ping all peers for a bucket and collect their responses
Returns a map of peer public key hex to their ping reply status. This waits for all pings to complete before returning.
§Arguments
bucket_id- The bucket to ping peers fortimeout- Optional timeout duration for the entire operation
Sourcepub async fn save_mount(&self, mount: &Mount) -> Result<Link, MountError>
pub async fn save_mount(&self, mount: &Mount) -> Result<Link, MountError>
Save a mount and append it to the bucket’s log
This method:
- Saves the mount to blobs, getting a new link
- Appends the new link to the bucket’s log
- Dispatches sync jobs to notify peers
§Arguments
bucket_id- The UUID of the bucketname- The name of the bucket (for log metadata)mount- The mount to save
§Returns
The new link where the mount was saved
§Errors
Returns error if:
- Failed to save mount to blobs
- Failed to append to log
Trait Implementations§
Source§impl<L> ProtocolHandler for Peer<L>
impl<L> ProtocolHandler for Peer<L>
Source§fn accept(
&self,
conn: Connection,
) -> BoxFuture<'static, Result<(), AcceptError>>
fn accept( &self, conn: Connection, ) -> BoxFuture<'static, Result<(), AcceptError>>
Handle an incoming connection. Read more
Source§fn on_connecting(
&self,
connecting: Connecting,
) -> impl Future<Output = Result<Connection, AcceptError>> + Send
fn on_connecting( &self, connecting: Connecting, ) -> impl Future<Output = Result<Connection, AcceptError>> + Send
Optional interception point to handle the
Connecting state. Read moreAuto Trait Implementations§
impl<L> Freeze for Peer<L>where
L: Freeze,
impl<L> !RefUnwindSafe for Peer<L>
impl<L> Send for Peer<L>
impl<L> Sync for Peer<L>
impl<L> Unpin for Peer<L>where
L: Unpin,
impl<L> !UnwindSafe for Peer<L>
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