pub struct NetworkContext { /* private fields */ }Expand description
Access control context for network-scoped blob and folder operations.
Wraps a NetworkManager and provides methods to verify that the local
node can access specific blobs or folders through its network memberships.
Implementations§
Source§impl NetworkContext
impl NetworkContext
Sourcepub fn from_manager(manager: &NetworkManager) -> Self
pub fn from_manager(manager: &NetworkManager) -> Self
Create a new network context from a NetworkManager.
Sourcepub fn new(database: NodeDatabase, local_node: &str) -> Self
pub fn new(database: NodeDatabase, local_node: &str) -> Self
Create a new network context directly from a database and local node ID.
Sourcepub fn can_access_folder(&self, namespace_id: &NamespaceId) -> Result<bool>
pub fn can_access_folder(&self, namespace_id: &NamespaceId) -> Result<bool>
Returns true if the local node can access the given folder namespace through at least one network membership.
§Errors
Returns an error if the database query fails.
Sourcepub fn can_access_blob(&self, hash: &Hash) -> Result<bool>
pub fn can_access_blob(&self, hash: &Hash) -> Result<bool>
Returns true if the local node can access the given blob through at least one folder in a network the node belongs to.
Uses the blob_folders reverse index for O(1) lookup.
§Errors
Returns an error if the database query fails.
Sourcepub fn networks_for_folder(
&self,
namespace_id: &NamespaceId,
) -> Result<Vec<String>>
pub fn networks_for_folder( &self, namespace_id: &NamespaceId, ) -> Result<Vec<String>>
List all network IDs (as strings) that contain the given folder.
§Errors
Returns an error if the database query fails.
Trait Implementations§
Source§impl Clone for NetworkContext
impl Clone for NetworkContext
Source§fn clone(&self) -> NetworkContext
fn clone(&self) -> NetworkContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for NetworkContext
impl RefUnwindSafe for NetworkContext
impl Send for NetworkContext
impl Sync for NetworkContext
impl Unpin for NetworkContext
impl UnsafeUnpin for NetworkContext
impl UnwindSafe for NetworkContext
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more