pub struct ObjectRequest {
pub truncate: bool,
/* private fields */
}
Expand description
Wraps the channel provided in the open methods and provide convenience methods for sending appropriate responses. It also records actions that should be taken upon successful connection such as truncating file objects.
Fields§
§truncate: bool
Truncate the object before use.
Implementations§
Source§impl ObjectRequest
impl ObjectRequest
Sourcepub fn new(flags: Flags, options: &Options, object_request: Channel) -> Self
pub fn new(flags: Flags, options: &Options, object_request: Channel) -> Self
Create a new ObjectRequest
from a set of fio::Flags
and fio::Options
`.
pub fn attributes(&self) -> NodeAttributesQuery
pub fn create_attributes(&self) -> Option<&MutableNodeAttributes>
pub fn options(&self) -> Options
Sourcepub async fn into_request_stream<T: Representation>(
self,
connection: &T,
) -> Result<<T::Protocol as ProtocolMarker>::RequestStream, Status>
pub async fn into_request_stream<T: Representation>( self, connection: &T, ) -> Result<<T::Protocol as ProtocolMarker>::RequestStream, Status>
Returns the request stream after sending requested information.
Sourcepub fn into_server_end<T>(self) -> ServerEnd<T>
pub fn into_server_end<T>(self) -> ServerEnd<T>
Converts to ServerEnd
Sourcepub fn into_channel(self) -> Channel
pub fn into_channel(self) -> Channel
Extracts the channel (without sending on_open).
Sourcepub fn into_channel_after_sending_on_open(
self,
node_info: NodeInfoDeprecated,
) -> Result<Channel, Status>
pub fn into_channel_after_sending_on_open( self, node_info: NodeInfoDeprecated, ) -> Result<Channel, Status>
Extracts the channel after sending on_open.
Sourcepub fn handle<T>(
self,
f: impl FnOnce(ObjectRequestRef<'_>) -> Result<T, Status>,
) -> Option<T>
pub fn handle<T>( self, f: impl FnOnce(ObjectRequestRef<'_>) -> Result<T, Status>, ) -> Option<T>
Calls f
and sends an error on the object request channel upon failure.
Sourcepub async fn handle_async(
self,
f: impl AsyncFnOnce(&mut ObjectRequest) -> Result<(), Status>,
)
pub async fn handle_async( self, f: impl AsyncFnOnce(&mut ObjectRequest) -> Result<(), Status>, )
Calls f
and sends an error on the object request channel upon failure.
Sourcepub async fn wait_till_ready(&self) -> bool
pub async fn wait_till_ready(&self) -> bool
Waits until the request has a request waiting in its channel. Returns immediately if this
request requires sending an initial event such as OnOpen or OnRepresentation. Returns
true
if the channel is readable (rather than just closed).
Sourcepub fn take(&mut self) -> ObjectRequest
pub fn take(&mut self) -> ObjectRequest
Take the ObjectRequest. The caller is responsible for sending errors.
Sourcepub async fn create_connection<C, N>(
&mut self,
scope: ExecutionScope,
node: Arc<N>,
protocols: impl ProtocolsExt,
) -> Result<(), Status>where
C: ConnectionCreator<N>,
N: Node,
pub async fn create_connection<C, N>(
&mut self,
scope: ExecutionScope,
node: Arc<N>,
protocols: impl ProtocolsExt,
) -> Result<(), Status>where
C: ConnectionCreator<N>,
N: Node,
Constructs a new connection to node
and spawns an async Task
that will handle requests
on the connection. f
is a callback that constructs the connection but it will not be
called if the connection is supposed to be a node connection. This should be called from
within a ObjectRequest::handle_async
callback.
Sourcepub fn create_connection_sync<C, N>(
self,
scope: ExecutionScope,
node: Arc<N>,
protocols: impl ProtocolsExt,
)where
C: ConnectionCreator<N>,
N: Node,
pub fn create_connection_sync<C, N>(
self,
scope: ExecutionScope,
node: Arc<N>,
protocols: impl ProtocolsExt,
)where
C: ConnectionCreator<N>,
N: Node,
Constructs a new connection to node
and spawns an async Task
that will handle requests
on the connection. f
is a callback that constructs the connection but it will not be
called if the connection is supposed to be a node connection. This should be called from
within a ObjectRequest::handle
callback.
This method synchronously calls async code and may require spawning an extra Task if the
async code does something asynchronous. create_connection
should be preferred if the
caller is already in an async context.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ObjectRequest
impl RefUnwindSafe for ObjectRequest
impl Send for ObjectRequest
impl Sync for ObjectRequest
impl Unpin for ObjectRequest
impl UnwindSafe for ObjectRequest
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
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
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