Struct safe_network::client::client_api::Client [−][src]
pub struct Client { /* fields omitted */ }
Expand description
Client object
Implementations
Reads Bytes
from the network, whose contents are contained within on or more chunks.
Read bytes from the network. The contents are spread across multiple chunks in the network. This function invokes the self-encryptor and returns the data that was initially stored.
Takes position
and length
arguments which specify the start position
and the length of bytes to be read.
Passing 0
to position reads the data from the beginning,
and the length
is just an upper limit.
Examples
TODO: update once data types are crdt compliant
Tries to chunk the bytes, returning an address and chunks, without storing anything to network.
Directly writes Bytes
to the network in the
form of immutable chunks, without any batching.
Directly writes Bytes
to the network in the
form of immutable chunks, without any batching.
It also attempts to verify that all the data was uploaded to the network before returning.
Calculates a Blob’s/Spot’s address from self encrypted chunks, without storing them onto the network.
Send a signed DataCmd to the network. This is to be part of a public API, for the user to provide the serialised and already signed command.
Send a Query to the network and await a response. Queries are automatically retried using exponential backoff if the timeout is hit.
Send a Query to the network and await a response. Queries are not retried if the timeout is hit.
Send a Query to the network and await a response. This is part of a public API, for the user to provide the serialised and already signed query.
Publish all register mutation operations in a WAL to the network Incrementing the WAL index as successful writes are sent out. Stops at the first error. Starts publishing from the index when called again with the same WAL.
pub async fn store_private_register(
&self,
name: XorName,
tag: u64,
owner: PublicKey,
permissions: BTreeMap<PublicKey, PrivatePermissions>
) -> Result<(Address, RegisterWriteAheadLog), Error>
pub async fn store_private_register(
&self,
name: XorName,
tag: u64,
owner: PublicKey,
permissions: BTreeMap<PublicKey, PrivatePermissions>
) -> Result<(Address, RegisterWriteAheadLog), Error>
Create a Private Register onto the Network
Creates a private Register on the network which can then be written to. Private data can be removed from the network at a later date.
Returns a write ahead log (WAL) of register operations, note that the changes are not uploaded to the
network until the WAL is published with publish_register_ops
A tag must be supplied. A xorname must be supplied, this can be random or deterministic as per your apps needs.
pub async fn store_public_register(
&self,
name: XorName,
tag: u64,
owner: PublicKey,
permissions: BTreeMap<User, PublicPermissions>
) -> Result<(Address, RegisterWriteAheadLog), Error>
pub async fn store_public_register(
&self,
name: XorName,
tag: u64,
owner: PublicKey,
permissions: BTreeMap<User, PublicPermissions>
) -> Result<(Address, RegisterWriteAheadLog), Error>
Create a Public Register onto the Network
Creates a public Register on the network which can then be written to. Public data can not be removed from the network at a later date.
Returns a write ahead log (WAL) of register operations, note that the changes are not uploaded to the
network until the WAL is published with publish_register_ops
A tag must be supplied. A xorname must be supplied, this can be random or deterministic as per your apps needs.
Delete Register
Returns a write ahead log (WAL) of register operations, note that the changes are not uploaded to the
network until the WAL is published with publish_register_ops
You’re only able to delete a PrivateRegister. Public data can not be removed from the network.
Write to Register
Returns a write ahead log (WAL) of register operations, note that the changes are not uploaded to the
network until the WAL is published with publish_register_ops
Public or private isn’t important for writing, though the data you write will be Public or Private according to the type of the targeted Register.
Get a Register from the Network
Get the last data entry from a Register data.
Get an entry from a Register on the Network by its hash
Get the owner of a Register.
pub async fn get_register_permissions_for_user(
&self,
address: Address,
user: PublicKey
) -> Result<Permissions, Error>
pub async fn get_register_permissions_for_user(
&self,
address: Address,
user: PublicKey
) -> Result<Permissions, Error>
Get the set of Permissions in a Register for a specific user.
Easily manage connections to/from The Safe Network with the client and its APIs. Use a random client for read-only or one-time operations. Supply an existing, SecretKey which holds a SafeCoin balance to be able to perform write operations.
pub async fn new(
config: ClientConfig,
bootstrap_nodes: BTreeSet<SocketAddr>,
optional_keypair: Option<Keypair>
) -> Result<Self, Error>
pub async fn new(
config: ClientConfig,
bootstrap_nodes: BTreeSet<SocketAddr>,
optional_keypair: Option<Keypair>
) -> Result<Self, Error>
Create a Safe Network client instance. Either for an existing SecretKey (in which case) the client will attempt to retrieve the history of the key’s balance in order to be ready for any token operations. Or if no SecreteKey is passed, a random keypair will be used, which provides a client that can only perform Read operations (at least until the client’s SecretKey receives some token).
Examples
TODO: update once data types are crdt compliant
Return the client’s keypair.
Useful for retrieving the PublicKey or KeyPair in the event you need to sign something
Examples
TODO: update once data types are crdt compliant
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
Blanket Implementations
Mutably borrows from an owned value. Read more
fn fg<C>(&'a self) -> FgColorDisplay<'a, C, Self> where
C: Color,
fn fg<C>(&'a self) -> FgColorDisplay<'a, C, Self> where
C: Color,
Set the foreground color generically Read more
fn bg<C>(&'a self) -> BgColorDisplay<'a, C, Self> where
C: Color,
fn bg<C>(&'a self) -> BgColorDisplay<'a, C, Self> where
C: Color,
Set the background color generically. Read more
fn black(&'a self) -> FgColorDisplay<'a, Black, Self>
fn black(&'a self) -> FgColorDisplay<'a, Black, Self>
Change the foreground color to black
fn on_black(&'a self) -> BgColorDisplay<'a, Black, Self>
fn on_black(&'a self) -> BgColorDisplay<'a, Black, Self>
Change the foreground color to black
fn red(&'a self) -> FgColorDisplay<'a, Red, Self>
fn red(&'a self) -> FgColorDisplay<'a, Red, Self>
Change the foreground color to red
fn on_red(&'a self) -> BgColorDisplay<'a, Red, Self>
fn on_red(&'a self) -> BgColorDisplay<'a, Red, Self>
Change the foreground color to red
fn green(&'a self) -> FgColorDisplay<'a, Green, Self>
fn green(&'a self) -> FgColorDisplay<'a, Green, Self>
Change the foreground color to green
fn on_green(&'a self) -> BgColorDisplay<'a, Green, Self>
fn on_green(&'a self) -> BgColorDisplay<'a, Green, Self>
Change the foreground color to green
fn yellow(&'a self) -> FgColorDisplay<'a, Yellow, Self>
fn yellow(&'a self) -> FgColorDisplay<'a, Yellow, Self>
Change the foreground color to yellow
fn on_yellow(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn on_yellow(&'a self) -> BgColorDisplay<'a, Yellow, Self>
Change the foreground color to yellow
fn blue(&'a self) -> FgColorDisplay<'a, Blue, Self>
fn blue(&'a self) -> FgColorDisplay<'a, Blue, Self>
Change the foreground color to blue
fn on_blue(&'a self) -> BgColorDisplay<'a, Blue, Self>
fn on_blue(&'a self) -> BgColorDisplay<'a, Blue, Self>
Change the foreground color to blue
fn magenta(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn magenta(&'a self) -> FgColorDisplay<'a, Magenta, Self>
Change the foreground color to magenta
fn on_magenta(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_magenta(&'a self) -> BgColorDisplay<'a, Magenta, Self>
Change the foreground color to magenta
fn purple(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn purple(&'a self) -> FgColorDisplay<'a, Magenta, Self>
Change the foreground color to purple
fn on_purple(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_purple(&'a self) -> BgColorDisplay<'a, Magenta, Self>
Change the foreground color to purple
fn cyan(&'a self) -> FgColorDisplay<'a, Cyan, Self>
fn cyan(&'a self) -> FgColorDisplay<'a, Cyan, Self>
Change the foreground color to cyan
fn on_cyan(&'a self) -> BgColorDisplay<'a, Cyan, Self>
fn on_cyan(&'a self) -> BgColorDisplay<'a, Cyan, Self>
Change the foreground color to cyan
fn white(&'a self) -> FgColorDisplay<'a, White, Self>
fn white(&'a self) -> FgColorDisplay<'a, White, Self>
Change the foreground color to white
fn on_white(&'a self) -> BgColorDisplay<'a, White, Self>
fn on_white(&'a self) -> BgColorDisplay<'a, White, Self>
Change the foreground color to white
fn bright_black(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
fn bright_black(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
Change the foreground color to bright black
fn on_bright_black(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
fn on_bright_black(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
Change the foreground color to bright black
fn bright_red(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
fn bright_red(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
Change the foreground color to bright red
fn on_bright_red(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
fn on_bright_red(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
Change the foreground color to bright red
fn bright_green(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
fn bright_green(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
Change the foreground color to bright green
fn on_bright_green(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
fn on_bright_green(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
Change the foreground color to bright green
fn bright_yellow(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
fn bright_yellow(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
Change the foreground color to bright yellow
fn on_bright_yellow(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
fn on_bright_yellow(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
Change the foreground color to bright yellow
fn bright_blue(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
fn bright_blue(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
Change the foreground color to bright blue
fn on_bright_blue(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
fn on_bright_blue(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
Change the foreground color to bright blue
fn bright_magenta(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_magenta(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
Change the foreground color to bright magenta
fn on_bright_magenta(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_magenta(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
Change the foreground color to bright magenta
fn bright_purple(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_purple(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
Change the foreground color to bright purple
fn on_bright_purple(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_purple(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
Change the foreground color to bright purple
fn bright_cyan(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
fn bright_cyan(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
Change the foreground color to bright cyan
fn on_bright_cyan(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
fn on_bright_cyan(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
Change the foreground color to bright cyan
fn bright_white(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
fn bright_white(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
Change the foreground color to bright white
fn on_bright_white(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
fn on_bright_white(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
Change the foreground color to bright white
fn bold(&'a self) -> BoldDisplay<'a, Self>
fn bold(&'a self) -> BoldDisplay<'a, Self>
Make the text bold
fn dimmed(&'a self) -> DimDisplay<'a, Self>
fn dimmed(&'a self) -> DimDisplay<'a, Self>
Make the text dim
fn italic(&'a self) -> ItalicDisplay<'a, Self>
fn italic(&'a self) -> ItalicDisplay<'a, Self>
Make the text italicized
fn underline(&'a self) -> UnderlineDisplay<'a, Self>
fn underline(&'a self) -> UnderlineDisplay<'a, Self>
Make the text italicized
fn blink(&'a self) -> BlinkDisplay<'a, Self>
fn blink(&'a self) -> BlinkDisplay<'a, Self>
Make the text blink
fn blink_fast(&'a self) -> BlinkFastDisplay<'a, Self>
fn blink_fast(&'a self) -> BlinkFastDisplay<'a, Self>
Make the text blink (but fast!)
fn reversed(&'a self) -> ReversedDisplay<'a, Self>
fn reversed(&'a self) -> ReversedDisplay<'a, Self>
Swap the foreground and background colors
Hide the text
fn strikethrough(&'a self) -> StrikeThroughDisplay<'a, Self>
fn strikethrough(&'a self) -> StrikeThroughDisplay<'a, Self>
Cross out the text
fn color<Color>(&'a self, color: Color) -> FgDynColorDisplay<'a, Color, Self> where
Color: DynColor,
fn color<Color>(&'a self, color: Color) -> FgDynColorDisplay<'a, Color, Self> where
Color: DynColor,
Set the foreground color at runtime. Only use if you do not know which color will be used at
compile-time. If the color is constant, use either OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read more
fn on_color<Color>(&'a self, color: Color) -> BgDynColorDisplay<'a, Color, Self> where
Color: DynColor,
fn on_color<Color>(&'a self, color: Color) -> BgDynColorDisplay<'a, Color, Self> where
Color: DynColor,
Set the background color at runtime. Only use if you do not know what color to use at
compile-time. If the color is constant, use either OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read more
Sets the foreground color to an RGB value.
fn on_truecolor(
&'a self,
r: u8,
g: u8,
b: u8
) -> BgDynColorDisplay<'a, Rgb, Self>
fn on_truecolor(
&'a self,
r: u8,
g: u8,
b: u8
) -> BgDynColorDisplay<'a, Rgb, Self>
Sets the background color to an RGB value.
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more