pub struct Library { /* private fields */ }Available on crate feature
i-scripts only.Expand description
A helper struct for interacting with libraries and functions.
let code = "#!lua name=mylib \n redis.register_function('myfunc', function(keys, args) return \
args[1] end)";
let library = Library::from_code(client, code).await?;
assert_eq!(library.name(), "mylib");
if let Some(func) = library.functions().get("myfunc") {
if func.flags().contains(&FunctionFlag::NoWrites) {
let _: () = func.fcall_ro(client, "key", "arg").await?;
} else {
let _: () = func.fcall(client, "key", "arg").await?;
}
}Implementations§
Source§impl Library
impl Library
Sourcepub async fn from_code<S>(
client: &RedisClient,
code: S,
) -> Result<Self, RedisError>
pub async fn from_code<S>( client: &RedisClient, code: S, ) -> Result<Self, RedisError>
Create a new Library with the provided code, loading it on all the servers and inspecting the contents via the FUNCTION LIST command.
This interface will load the library on the server.
Sourcepub async fn from_name<S>(
client: &RedisClient,
name: S,
) -> Result<Self, RedisError>
pub async fn from_name<S>( client: &RedisClient, name: S, ) -> Result<Self, RedisError>
Create a new Library with the associated name, inspecting the library contents via the FUNCTION LIST command.
This interface assumes the library is already loaded on the server.
Trait Implementations§
Source§impl Ord for Library
impl Ord for Library
Source§impl PartialOrd for Library
impl PartialOrd for Library
impl Eq for Library
impl StructuralPartialEq for Library
Auto Trait Implementations§
impl !Freeze for Library
impl RefUnwindSafe for Library
impl Send for Library
impl Sync for Library
impl Unpin for Library
impl UnwindSafe for Library
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)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> 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>
Converts
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>
Converts
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