pub struct PlmClient { /* private fields */ }Expand description
One PLM server, and who the app is on it.
Implementations§
Source§impl PlmClient
impl PlmClient
pub fn new(transport: Rc<dyn PlmTransport>) -> Self
Sourcepub fn me(&self) -> Option<Me>
pub fn me(&self) -> Option<Me>
Who the client is signed in as, once a sign-in has passed the version check.
pub fn credential(&self) -> Credential
Sourcepub fn forget(&self)
pub fn forget(&self)
Forget the credential locally. (A token stays valid on the server; the user revokes it on the PLM’s page.)
Sourcepub async fn raw(
&self,
method: &'static str,
path: &str,
body: Option<Vec<u8>>,
) -> Result<PlmResponse, PlmError>
pub async fn raw( &self, method: &'static str, path: &str, body: Option<Vec<u8>>, ) -> Result<PlmResponse, PlmError>
One call with the current credential. Every status comes back Ok;
only a request that got no answer is an Err.
Sourcepub async fn sign_in_with_token(&self, token: &str) -> Result<Me, PlmError>
pub async fn sign_in_with_token(&self, token: &str) -> Result<Me, PlmError>
Sign in with a token (pasted, or read from plm-token). Passes only if
the server accepts the token AND its version serves this app.
Sourcepub async fn sign_in_with_browser_session(&self) -> Result<Me, PlmError>
pub async fn sign_in_with_browser_session(&self) -> Result<Me, PlmError>
The page is served by the PLM and the browser already holds a session cookie (D6): adopt it, and read the CSRF token changes must carry.
Sourcepub async fn sign_in_with_password(
&self,
username: &str,
password: &str,
) -> Result<Me, PlmError>
pub async fn sign_in_with_password( &self, username: &str, password: &str, ) -> Result<Me, PlmError>
Sign in with a username and password as a SESSION (the web lane, D6).
Sourcepub async fn sign_in_for_token(
&self,
username: &str,
password: &str,
token_name: &str,
) -> Result<(Me, String), PlmError>
pub async fn sign_in_for_token( &self, username: &str, password: &str, token_name: &str, ) -> Result<(Me, String), PlmError>
Trade a username and password for a token (the native lane, D5): sign
in, mint a full token named token_name through that session, sign
the session out, and sign in with the token. Returns the token for the
caller to keep (plm::config::write_token); the password is not kept.
Sourcepub async fn index(&self) -> Result<StoreIndex, PlmError>
pub async fn index(&self) -> Result<StoreIndex, PlmError>
GET /api/store/index.
Sourcepub async fn index_rows(&self, keys: &[String]) -> Result<StoreIndex, PlmError>
pub async fn index_rows(&self, keys: &[String]) -> Result<StoreIndex, PlmError>
GET /api/store/index?keys=…: only those revisions’ rows (a key that
names no revision any more is absent from the answer).
Sourcepub async fn get_document(&self, key: &str) -> Result<Option<Vec<u8>>, PlmError>
pub async fn get_document(&self, key: &str) -> Result<Option<Vec<u8>>, PlmError>
GET /api/store/doc/<key>: the bytes, or None when the revision has
no document yet (204). A revision that does not exist is
PlmError::NotFound.
Sourcepub async fn put_document(
&self,
key: &str,
bytes: Vec<u8>,
) -> Result<PutAck, PlmError>
pub async fn put_document( &self, key: &str, bytes: Vec<u8>, ) -> Result<PutAck, PlmError>
PUT /api/store/doc/<key>. Needs the lock and an editable revision;
otherwise PlmError::Conflict with the server’s sentence.
Sourcepub async fn delete_document(&self, key: &str) -> Result<(), PlmError>
pub async fn delete_document(&self, key: &str) -> Result<(), PlmError>
DELETE /api/store/doc/<key>, under the same two conditions as a write.
Sourcepub async fn get_preference(
&self,
name: &str,
) -> Result<Option<String>, PlmError>
pub async fn get_preference( &self, name: &str, ) -> Result<Option<String>, PlmError>
GET /api/me/preferences/<name> (@settings, …): the value, or None
when the user has never set it. Unset is 204 No Content (server B,
2026-09-25: a hosted page’s console logs every 404) and was 404
before; both read as unset.
Sourcepub async fn put_preference(
&self,
name: &str,
value: String,
) -> Result<(), PlmError>
pub async fn put_preference( &self, name: &str, value: String, ) -> Result<(), PlmError>
PUT /api/me/preferences/<name> with the value, which must be JSON.
Auto Trait Implementations§
impl !Freeze for PlmClient
impl !RefUnwindSafe for PlmClient
impl !Send for PlmClient
impl !Sync for PlmClient
impl !UnwindSafe for PlmClient
impl Unpin for PlmClient
impl UnsafeUnpin for PlmClient
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.